|
@@ -1,5 +1,7 @@
|
|
|
<?php
|
|
<?php
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * String output example (console QR Codes for Lynx users!)
|
|
|
|
|
+ *
|
|
|
* @created 21.12.2017
|
|
* @created 21.12.2017
|
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
|
* @copyright 2017 Smiley
|
|
* @copyright 2017 Smiley
|
|
@@ -11,59 +13,51 @@ namespace chillerlan\QRCodeExamples;
|
|
|
use chillerlan\QRCode\{QRCode, QROptions};
|
|
use chillerlan\QRCode\{QRCode, QROptions};
|
|
|
use chillerlan\QRCode\Data\QRMatrix;
|
|
use chillerlan\QRCode\Data\QRMatrix;
|
|
|
use chillerlan\QRCode\Common\EccLevel;
|
|
use chillerlan\QRCode\Common\EccLevel;
|
|
|
|
|
+use PHPUnit\Util\Color;
|
|
|
|
|
|
|
|
require_once __DIR__.'/../vendor/autoload.php';
|
|
require_once __DIR__.'/../vendor/autoload.php';
|
|
|
|
|
|
|
|
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
|
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
|
|
|
|
|
|
|
|
$options = new QROptions([
|
|
$options = new QROptions([
|
|
|
- 'version' => 5,
|
|
|
|
|
- 'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
|
|
|
|
- 'eccLevel' => EccLevel::L,
|
|
|
|
|
-]);
|
|
|
|
|
-
|
|
|
|
|
-// <pre> to view it in a browser
|
|
|
|
|
-echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// custom values
|
|
|
|
|
-$options = new QROptions([
|
|
|
|
|
- 'version' => 5,
|
|
|
|
|
|
|
+ 'version' => 7,
|
|
|
'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
|
'outputType' => QRCode::OUTPUT_STRING_TEXT,
|
|
|
'eccLevel' => EccLevel::L,
|
|
'eccLevel' => EccLevel::L,
|
|
|
|
|
+ 'eol' => Color::colorize('reset', "\x00\n"),
|
|
|
'moduleValues' => [
|
|
'moduleValues' => [
|
|
|
// finder
|
|
// finder
|
|
|
- QRMatrix::M_FINDER | QRMatrix::IS_DARK => 'A', // dark (true)
|
|
|
|
|
- QRMatrix::M_FINDER => 'a', // light (false)
|
|
|
|
|
- QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 'ä', // finder dot, dark (true)
|
|
|
|
|
|
|
+ QRMatrix::M_FINDER | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // dark (true)
|
|
|
|
|
+ QRMatrix::M_FINDER => Color::colorize('fg-black', '⭕'), // light (false)
|
|
|
|
|
+ QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // finder dot, dark (true)
|
|
|
// alignment
|
|
// alignment
|
|
|
- QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 'B',
|
|
|
|
|
- QRMatrix::M_ALIGNMENT => 'b',
|
|
|
|
|
|
|
+ QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => Color::colorize('fg-blue', '🔴'),
|
|
|
|
|
+ QRMatrix::M_ALIGNMENT => Color::colorize('fg-blue', '⭕'),
|
|
|
// timing
|
|
// timing
|
|
|
- QRMatrix::M_TIMING | QRMatrix::IS_DARK => 'C',
|
|
|
|
|
- QRMatrix::M_TIMING => 'c',
|
|
|
|
|
|
|
+ QRMatrix::M_TIMING | QRMatrix::IS_DARK => Color::colorize('fg-red', '🔴'),
|
|
|
|
|
+ QRMatrix::M_TIMING => Color::colorize('fg-red', '⭕'),
|
|
|
// format
|
|
// format
|
|
|
- QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 'D',
|
|
|
|
|
- QRMatrix::M_FORMAT => 'd',
|
|
|
|
|
|
|
+ QRMatrix::M_FORMAT | QRMatrix::IS_DARK => Color::colorize('fg-magenta', '🔴'),
|
|
|
|
|
+ QRMatrix::M_FORMAT => Color::colorize('fg-magenta', '⭕'),
|
|
|
// version
|
|
// version
|
|
|
- QRMatrix::M_VERSION | QRMatrix::IS_DARK => 'E',
|
|
|
|
|
- QRMatrix::M_VERSION => 'e',
|
|
|
|
|
|
|
+ QRMatrix::M_VERSION | QRMatrix::IS_DARK => Color::colorize('fg-green', '🔴'),
|
|
|
|
|
+ QRMatrix::M_VERSION => Color::colorize('fg-green', '⭕'),
|
|
|
// data
|
|
// data
|
|
|
- QRMatrix::M_DATA | QRMatrix::IS_DARK => 'F',
|
|
|
|
|
- QRMatrix::M_DATA => 'f',
|
|
|
|
|
|
|
+ QRMatrix::M_DATA | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'),
|
|
|
|
|
+ QRMatrix::M_DATA => Color::colorize('fg-white', '⭕'),
|
|
|
// darkmodule
|
|
// darkmodule
|
|
|
- QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 'G',
|
|
|
|
|
|
|
+ QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'),
|
|
|
// separator
|
|
// separator
|
|
|
- QRMatrix::M_SEPARATOR => 'h',
|
|
|
|
|
|
|
+ QRMatrix::M_SEPARATOR => Color::colorize('fg-cyan', '⭕'),
|
|
|
// quietzone
|
|
// quietzone
|
|
|
- QRMatrix::M_QUIETZONE => 'i',
|
|
|
|
|
|
|
+ QRMatrix::M_QUIETZONE => Color::colorize('fg-cyan', '⭕'),
|
|
|
|
|
+ // logo space
|
|
|
|
|
+ QRMatrix::M_LOGO => Color::colorize('fg-yellow', '⭕'),
|
|
|
|
|
+ // empty
|
|
|
|
|
+ QRMatrix::M_NULL => Color::colorize('fg-black', '⭕'),
|
|
|
|
|
+ // data
|
|
|
|
|
+ QRMatrix::M_TEST | QRMatrix::IS_DARK => Color::colorize('fg-white', '🔴'),
|
|
|
|
|
+ QRMatrix::M_TEST => Color::colorize('fg-black', '⭕'),
|
|
|
],
|
|
],
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
-// <pre> to view it in a browser
|
|
|
|
|
-echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+echo (new QRCode($options))->render($data);
|