From 6f001c42d9faf8259ebf0fa4a5699bdce28cb6f2 Mon Sep 17 00:00:00 2001 From: codemasher Date: Sun, 12 Dec 2021 23:42:04 +0100 Subject: [PATCH] :shower: updated examples --- examples/QRImageWithLogo.php | 4 ++-- examples/QRImageWithText.php | 10 +++++----- examples/imageWithLogo.php | 22 +++++++++++++--------- examples/imagick.php | 5 +++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/examples/QRImageWithLogo.php b/examples/QRImageWithLogo.php index 431dddbf6..788a16417 100644 --- a/examples/QRImageWithLogo.php +++ b/examples/QRImageWithLogo.php @@ -12,11 +12,11 @@ namespace chillerlan\QRCodeExamples; -use chillerlan\QRCode\Output\{QRCodeOutputException, QRImage}; +use chillerlan\QRCode\Output\{QRGdImage, QRCodeOutputException}; use function imagecopyresampled, imagecreatefrompng, imagesx, imagesy, is_file, is_readable; -class QRImageWithLogo extends QRImage{ +class QRImageWithLogo extends QRGdImage{ /** * @param string|null $file diff --git a/examples/QRImageWithText.php b/examples/QRImageWithText.php index b5971bdf1..9bf91d276 100644 --- a/examples/QRImageWithText.php +++ b/examples/QRImageWithText.php @@ -16,12 +16,12 @@ namespace chillerlan\QRCodeExamples; -use chillerlan\QRCode\Output\QRImage; - +use chillerlan\QRCode\Output\QRGdImage; +use chillerlan\QRCode\QRCode; use function imagechar, imagecolorallocate, imagecolortransparent, imagecopymerge, imagecreatetruecolor, - imagedestroy, imagefilledrectangle, imagefontwidth, in_array, round, str_split, strlen; + imagedestroy, imagefilledrectangle, imagefontwidth, round, str_split, strlen; -class QRImageWithText extends QRImage{ +class QRImageWithText extends QRGdImage{ /** * @param string|null $file @@ -74,7 +74,7 @@ class QRImageWithText extends QRImage{ $background = imagecolorallocate($this->image, ...$textBG); // allow transparency - if($this->options->imageTransparent && in_array($this->options->outputType, $this::TRANSPARENCY_TYPES, true)){ + if($this->options->imageTransparent && $this->options->outputType !== QRCode::OUTPUT_IMAGE_JPG){ imagecolortransparent($this->image, $background); } diff --git a/examples/imageWithLogo.php b/examples/imageWithLogo.php index f61be2c66..2f929a9e6 100644 --- a/examples/imageWithLogo.php +++ b/examples/imageWithLogo.php @@ -10,20 +10,24 @@ namespace chillerlan\QRCodeExamples; use chillerlan\QRCode\{QRCode, QROptions}; use chillerlan\QRCode\Common\EccLevel; +use chillerlan\QRCode\Data\QRMatrix; require_once __DIR__.'/../vendor/autoload.php'; -$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; +$data = 'https://github.com'; $options = new QROptions([ - 'version' => 7, - 'eccLevel' => EccLevel::H, - 'imageBase64' => false, - 'addLogoSpace' => true, - 'logoSpaceWidth' => 13, - 'logoSpaceHeight' => 13, - 'scale' => 5, - 'imageTransparent' => false, + 'version' => 5, + 'eccLevel' => EccLevel::H, + 'imageBase64' => false, + 'addLogoSpace' => true, + 'logoSpaceWidth' => 13, + 'logoSpaceHeight' => 13, + 'scale' => 6, + 'imageTransparent' => false, + 'drawCircularModules' => true, + 'circleRadius' => 0.45, + 'keepAsSquare' => [QRMatrix::M_FINDER, QRMatrix::M_FINDER_DOT], ]); $qrcode = new QRCode($options); diff --git a/examples/imagick.php b/examples/imagick.php index e64a5d80c..2cb06ad8d 100644 --- a/examples/imagick.php +++ b/examples/imagick.php @@ -14,12 +14,13 @@ use chillerlan\QRCode\Common\EccLevel; require_once __DIR__.'/../vendor/autoload.php'; -$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; +$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'; $options = new QROptions([ 'version' => 7, 'outputType' => QRCode::OUTPUT_IMAGICK, 'eccLevel' => EccLevel::L, + 'imagickBG' => '#FFFFFF', 'scale' => 20, 'drawCircularModules' => true, 'circleRadius' => 0.4, @@ -37,7 +38,7 @@ $options = new QROptions([ QRMatrix::M_TIMING => '#FFB8E9', // format QRMatrix::M_FORMAT | QRMatrix::IS_DARK => '#003804', - QRMatrix::M_FORMAT => '#00FB12', + QRMatrix::M_FORMAT => '#CCFB12', // version QRMatrix::M_VERSION | QRMatrix::IS_DARK => '#650098', QRMatrix::M_VERSION => '#E0B8FF',