text.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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, QRStringText};
  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->moduleValues = [
  21. QRMatrix::M_FINDER_DARK => QRStringText::ansi8('██', 124),
  22. QRMatrix::M_FINDER => QRStringText::ansi8('░░', 124),
  23. QRMatrix::M_FINDER_DOT => QRStringText::ansi8('██', 124),
  24. QRMatrix::M_ALIGNMENT_DARK => QRStringText::ansi8('██', 2),
  25. QRMatrix::M_ALIGNMENT => QRStringText::ansi8('░░', 2),
  26. QRMatrix::M_TIMING_DARK => QRStringText::ansi8('██', 184),
  27. QRMatrix::M_TIMING => QRStringText::ansi8('░░', 184),
  28. QRMatrix::M_FORMAT_DARK => QRStringText::ansi8('██', 200),
  29. QRMatrix::M_FORMAT => QRStringText::ansi8('░░', 200),
  30. QRMatrix::M_VERSION_DARK => QRStringText::ansi8('██', 21),
  31. QRMatrix::M_VERSION => QRStringText::ansi8('░░', 21),
  32. QRMatrix::M_DARKMODULE => QRStringText::ansi8('██', 53),
  33. QRMatrix::M_DATA_DARK => QRStringText::ansi8('██', 166),
  34. QRMatrix::M_DATA => QRStringText::ansi8('░░', 166),
  35. QRMatrix::M_QUIETZONE => QRStringText::ansi8('░░', 253),
  36. QRMatrix::M_SEPARATOR => QRStringText::ansi8('░░', 253),
  37. ];
  38. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  39. echo "\n\n\n$out\n\n\n";
  40. exit;