From 3cedde5ee4bee757b0a0f6763f4efd48198d6dc5 Mon Sep 17 00:00:00 2001 From: smiley Date: Fri, 27 May 2022 18:59:04 +0200 Subject: [PATCH] :shower: updated string output example --- examples/text.php | 64 +++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/examples/text.php b/examples/text.php index bc24ddf28..e85f91b4f 100644 --- a/examples/text.php +++ b/examples/text.php @@ -1,5 +1,7 @@ * @copyright 2017 Smiley @@ -11,59 +13,51 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Common\EccLevel; +use PHPUnit\Util\Color; require_once __DIR__.'/../vendor/autoload.php'; $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; $options = new QROptions([ - 'version' => 5, - 'outputType' => QRCode::OUTPUT_STRING_TEXT, - 'eccLevel' => EccLevel::L, -]); - -//
 to view it in a browser
-echo '
'.(new QRCode($options))->render($data).'
'; - - -// custom values -$options = new QROptions([ - 'version' => 5, + 'version' => 7, 'outputType' => QRCode::OUTPUT_STRING_TEXT, 'eccLevel' => EccLevel::L, + 'eol' => Color::colorize('reset', "\x00\n"), 'moduleValues' => [ // 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 - 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 - 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 - 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 - 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 - 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 - QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 'G', + QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => Color::colorize('fg-black', '🔴'), // separator - QRMatrix::M_SEPARATOR => 'h', + QRMatrix::M_SEPARATOR => Color::colorize('fg-cyan', '⭕'), // 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', '⭕'), ], ]); -//
 to view it in a browser
-echo '
'.(new QRCode($options))->render($data).'
'; - - - - - +echo (new QRCode($options))->render($data);