text.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. declare(strict_types=1);
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\QRStringText;
  14. require_once __DIR__.'/../vendor/autoload.php';
  15. $options = new QROptions;
  16. $options->version = 3;
  17. $options->quietzoneSize = 2;
  18. $options->outputInterface = QRStringText::class;
  19. $options->eol = "\n";
  20. $options->textLineStart = str_repeat(' ', 6);
  21. $options->moduleValues = [
  22. QRMatrix::M_FINDER_DARK => QRStringText::ansi8('██', 124),
  23. QRMatrix::M_FINDER => QRStringText::ansi8('░░', 124),
  24. QRMatrix::M_FINDER_DOT => QRStringText::ansi8('██', 124),
  25. QRMatrix::M_ALIGNMENT_DARK => QRStringText::ansi8('██', 2),
  26. QRMatrix::M_ALIGNMENT => QRStringText::ansi8('░░', 2),
  27. QRMatrix::M_TIMING_DARK => QRStringText::ansi8('██', 184),
  28. QRMatrix::M_TIMING => QRStringText::ansi8('░░', 184),
  29. QRMatrix::M_FORMAT_DARK => QRStringText::ansi8('██', 200),
  30. QRMatrix::M_FORMAT => QRStringText::ansi8('░░', 200),
  31. QRMatrix::M_VERSION_DARK => QRStringText::ansi8('██', 21),
  32. QRMatrix::M_VERSION => QRStringText::ansi8('░░', 21),
  33. QRMatrix::M_DARKMODULE => QRStringText::ansi8('██', 53),
  34. QRMatrix::M_DATA_DARK => QRStringText::ansi8('██', 166),
  35. QRMatrix::M_DATA => QRStringText::ansi8('░░', 166),
  36. QRMatrix::M_QUIETZONE => QRStringText::ansi8('░░', 253),
  37. QRMatrix::M_SEPARATOR => QRStringText::ansi8('░░', 253),
  38. ];
  39. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  40. printf("\n\n\n%s\n\n\n", $out);
  41. exit;