Browse Source

:shower: updated examples

codemasher 4 years ago
parent
commit
6f001c42d9
4 changed files with 23 additions and 18 deletions
  1. 2 2
      examples/QRImageWithLogo.php
  2. 5 5
      examples/QRImageWithText.php
  3. 13 9
      examples/imageWithLogo.php
  4. 3 2
      examples/imagick.php

+ 2 - 2
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

+ 5 - 5
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);
 		}
 

+ 13 - 9
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);

+ 3 - 2
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',