text.php 2.6 KB

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