text.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Common\EccLevel;
  13. use PHPUnit\Util\Color;
  14. require_once __DIR__.'/../vendor/autoload.php';
  15. $options = new QROptions([
  16. 'version' => 7,
  17. 'outputType' => QRCode::OUTPUT_STRING_TEXT,
  18. 'eccLevel' => EccLevel::L,
  19. 'eol' => Color::colorize('reset', "\x00\n"),
  20. 'moduleValues' => [
  21. // finder
  22. QRMatrix::M_FINDER | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // dark (true)
  23. QRMatrix::M_FINDER => Color::colorize('fg-black', '⭕'), // light (false)
  24. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // finder dot, dark (true)
  25. // alignment
  26. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => Color::colorize('fg-blue', '🔴'),
  27. QRMatrix::M_ALIGNMENT => Color::colorize('fg-blue', '⭕'),
  28. // timing
  29. QRMatrix::M_TIMING | QRMatrix::IS_DARK => Color::colorize('fg-red', '🔴'),
  30. QRMatrix::M_TIMING => Color::colorize('fg-red', '⭕'),
  31. // format
  32. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => Color::colorize('fg-magenta', '🔴'),
  33. QRMatrix::M_FORMAT => Color::colorize('fg-magenta', '⭕'),
  34. // version
  35. QRMatrix::M_VERSION | QRMatrix::IS_DARK => Color::colorize('fg-green', '🔴'),
  36. QRMatrix::M_VERSION => Color::colorize('fg-green', '⭕'),
  37. // data
  38. QRMatrix::M_DATA | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'),
  39. QRMatrix::M_DATA => Color::colorize('fg-white', '⭕'),
  40. // darkmodule
  41. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'),
  42. // separator
  43. QRMatrix::M_SEPARATOR => Color::colorize('fg-cyan', '⭕'),
  44. // quietzone
  45. QRMatrix::M_QUIETZONE => Color::colorize('fg-cyan', '⭕'),
  46. // logo space
  47. QRMatrix::M_LOGO => Color::colorize('fg-yellow', '⭕'),
  48. // empty
  49. QRMatrix::M_NULL => Color::colorize('fg-black', '⭕'),
  50. // data
  51. QRMatrix::M_TEST | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'),
  52. QRMatrix::M_TEST => Color::colorize('fg-black', '⭕'),
  53. ],
  54. ]);
  55. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  56. exit;