Skip to content

Commit 3cedde5

Browse files
committed
🚿 updated string output example
1 parent c4b234b commit 3cedde5

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

examples/text.php

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22
/**
3+
* String output example (console QR Codes for Lynx users!)
4+
*
35
* @created 21.12.2017
46
* @author Smiley <[email protected]>
57
* @copyright 2017 Smiley
@@ -11,59 +13,51 @@
1113
use chillerlan\QRCode\{QRCode, QROptions};
1214
use chillerlan\QRCode\Data\QRMatrix;
1315
use chillerlan\QRCode\Common\EccLevel;
16+
use PHPUnit\Util\Color;
1417

1518
require_once __DIR__.'/../vendor/autoload.php';
1619

1720
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
1821

1922
$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,
3224
'outputType' => QRCode::OUTPUT_STRING_TEXT,
3325
'eccLevel' => EccLevel::L,
26+
'eol' => Color::colorize('reset', "\x00\n"),
3427
'moduleValues' => [
3528
// 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)
3932
// 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', ''),
4235
// 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', ''),
4538
// 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', ''),
4841
// 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', ''),
5144
// 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', ''),
5447
// darkmodule
55-
QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 'G',
48+
QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'),
5649
// separator
57-
QRMatrix::M_SEPARATOR => 'h',
50+
QRMatrix::M_SEPARATOR => Color::colorize('fg-cyan', ''),
5851
// 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', ''),
6060
],
6161
]);
6262

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

Comments
 (0)