|
1 | 1 | <?php
|
2 | 2 | /**
|
| 3 | + * String output example (console QR Codes for Lynx users!) |
| 4 | + * |
3 | 5 | * @created 21.12.2017
|
4 | 6 | * @author Smiley <[email protected]>
|
5 | 7 | * @copyright 2017 Smiley
|
|
11 | 13 | use chillerlan\QRCode\{QRCode, QROptions};
|
12 | 14 | use chillerlan\QRCode\Data\QRMatrix;
|
13 | 15 | use chillerlan\QRCode\Common\EccLevel;
|
| 16 | +use PHPUnit\Util\Color; |
14 | 17 |
|
15 | 18 | require_once __DIR__.'/../vendor/autoload.php';
|
16 | 19 |
|
17 | 20 | $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
18 | 21 |
|
19 | 22 | $options = new QROptions([
|
20 |
| - 'version' => 5, |
21 |
| - 'outputType' => QRCode::OUTPUT_STRING_TEXT, |
22 |
| - 'eccLevel' => EccLevel::L, |
23 |
| -]); |
24 |
| - |
25 |
| -// <pre> to view it in a browser |
26 |
| -echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>'; |
27 |
| - |
28 |
| - |
29 |
| -// custom values |
30 |
| -$options = new QROptions([ |
31 |
| - 'version' => 5, |
| 23 | + 'version' => 7, |
32 | 24 | 'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
33 | 25 | 'eccLevel' => EccLevel::L,
|
| 26 | + 'eol' => Color::colorize('reset', "\x00\n"), |
34 | 27 | 'moduleValues' => [
|
35 | 28 | // finder
|
36 |
| - QRMatrix::M_FINDER | QRMatrix::IS_DARK => 'A', // dark (true) |
37 |
| - QRMatrix::M_FINDER => 'a', // light (false) |
38 |
| - QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 'ä', // finder dot, dark (true) |
| 29 | + QRMatrix::M_FINDER | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // dark (true) |
| 30 | + QRMatrix::M_FINDER => Color::colorize('fg-black', '⭕'), // light (false) |
| 31 | + QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // finder dot, dark (true) |
39 | 32 | // alignment
|
40 |
| - QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 'B', |
41 |
| - QRMatrix::M_ALIGNMENT => 'b', |
| 33 | + QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => Color::colorize('fg-blue', '🔴'), |
| 34 | + QRMatrix::M_ALIGNMENT => Color::colorize('fg-blue', '⭕'), |
42 | 35 | // timing
|
43 |
| - QRMatrix::M_TIMING | QRMatrix::IS_DARK => 'C', |
44 |
| - QRMatrix::M_TIMING => 'c', |
| 36 | + QRMatrix::M_TIMING | QRMatrix::IS_DARK => Color::colorize('fg-red', '🔴'), |
| 37 | + QRMatrix::M_TIMING => Color::colorize('fg-red', '⭕'), |
45 | 38 | // format
|
46 |
| - QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 'D', |
47 |
| - QRMatrix::M_FORMAT => 'd', |
| 39 | + QRMatrix::M_FORMAT | QRMatrix::IS_DARK => Color::colorize('fg-magenta', '🔴'), |
| 40 | + QRMatrix::M_FORMAT => Color::colorize('fg-magenta', '⭕'), |
48 | 41 | // version
|
49 |
| - QRMatrix::M_VERSION | QRMatrix::IS_DARK => 'E', |
50 |
| - QRMatrix::M_VERSION => 'e', |
| 42 | + QRMatrix::M_VERSION | QRMatrix::IS_DARK => Color::colorize('fg-green', '🔴'), |
| 43 | + QRMatrix::M_VERSION => Color::colorize('fg-green', '⭕'), |
51 | 44 | // data
|
52 |
| - QRMatrix::M_DATA | QRMatrix::IS_DARK => 'F', |
53 |
| - QRMatrix::M_DATA => 'f', |
| 45 | + QRMatrix::M_DATA | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'), |
| 46 | + QRMatrix::M_DATA => Color::colorize('fg-white', '⭕'), |
54 | 47 | // darkmodule
|
55 |
| - QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 'G', |
| 48 | + QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), |
56 | 49 | // separator
|
57 |
| - QRMatrix::M_SEPARATOR => 'h', |
| 50 | + QRMatrix::M_SEPARATOR => Color::colorize('fg-cyan', '⭕'), |
58 | 51 | // quietzone
|
59 |
| - QRMatrix::M_QUIETZONE => 'i', |
| 52 | + QRMatrix::M_QUIETZONE => Color::colorize('fg-cyan', '⭕'), |
| 53 | + // logo space |
| 54 | + QRMatrix::M_LOGO => Color::colorize('fg-yellow', '⭕'), |
| 55 | + // empty |
| 56 | + QRMatrix::M_NULL => Color::colorize('fg-black', '⭕'), |
| 57 | + // data |
| 58 | + QRMatrix::M_TEST | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'), |
| 59 | + QRMatrix::M_TEST => Color::colorize('fg-black', '⭕'), |
60 | 60 | ],
|
61 | 61 | ]);
|
62 | 62 |
|
63 |
| -// <pre> to view it in a browser |
64 |
| -echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>'; |
65 |
| - |
66 |
| - |
67 |
| - |
68 |
| - |
69 |
| - |
| 63 | +echo (new QRCode($options))->render($data); |
0 commit comments