text.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * String output example (console QR Codes for Lynx users!)
  4. *
  5. * @created 21.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. use chillerlan\QRCode\{QRCode, QROptions};
  11. use chillerlan\QRCode\Data\QRMatrix;
  12. use chillerlan\QRCode\Output\{QROutputInterface, QRString};
  13. require_once __DIR__.'/../vendor/autoload.php';
  14. $options = new QROptions;
  15. $options->version = 3;
  16. $options->quietzoneSize = 2;
  17. $options->outputType = QROutputInterface::STRING_TEXT;
  18. $options->eol = "\n";
  19. $options->textLineStart = str_repeat(' ', 6);
  20. $options->textDark = QRString::ansi8('██', 253);
  21. $options->textLight = QRString::ansi8('░░', 253);
  22. $options->moduleValues = [
  23. // finder
  24. QRMatrix::M_FINDER_DARK => QRString::ansi8('██', 124),
  25. QRMatrix::M_FINDER => QRString::ansi8('░░', 124),
  26. QRMatrix::M_FINDER_DOT => QRString::ansi8('██', 124),
  27. // alignment
  28. QRMatrix::M_ALIGNMENT_DARK => QRString::ansi8('██', 2),
  29. QRMatrix::M_ALIGNMENT => QRString::ansi8('░░', 2),
  30. // timing
  31. QRMatrix::M_TIMING_DARK => QRString::ansi8('██', 184),
  32. QRMatrix::M_TIMING => QRString::ansi8('░░', 184),
  33. // format
  34. QRMatrix::M_FORMAT_DARK => QRString::ansi8('██', 200),
  35. QRMatrix::M_FORMAT => QRString::ansi8('░░', 200),
  36. // version
  37. QRMatrix::M_VERSION_DARK => QRString::ansi8('██', 21),
  38. QRMatrix::M_VERSION => QRString::ansi8('░░', 21),
  39. // dark module
  40. QRMatrix::M_DARKMODULE => QRString::ansi8('██', 53),
  41. // data
  42. QRMatrix::M_DATA_DARK => QRString::ansi8('██', 166),
  43. QRMatrix::M_DATA => QRString::ansi8('░░', 166),
  44. ];
  45. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  46. echo "\n\n\n$out\n\n\n";
  47. exit;