smiley преди 1 месец
родител
ревизия
e5e9009aab
променени са 5 файла, в които са добавени 10 реда и са изтрити 7 реда
  1. 0 1
      examples/imageWithText.php
  2. 1 1
      examples/svgMeltedModules.php
  3. 6 2
      examples/svgModuleGroupShape.php
  4. 1 1
      examples/svgRandomColoredDots.php
  5. 2 2
      examples/svgRoundQuietzone.php

+ 0 - 1
examples/imageWithText.php

@@ -73,7 +73,6 @@ class QRImageWithText extends QRGdImagePNG{
 
 		// copy over the qrcode
 		imagecopymerge($this->image, $qrcode, 0, 0, 0, 0, $this->length, $this->length, 100);
-		imagedestroy($qrcode);
 
 		$fontColor = imagecolorallocate($this->image, ...$textColor);
 		$w         = imagefontwidth($textSize);

+ 1 - 1
examples/svgMeltedModules.php

@@ -59,7 +59,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{
 				// collect the modules per $M_TYPE
 				$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
 
-				if(!empty($module)){
+				if($module !== null){
 					$paths[$M_TYPE_LAYER][] = $module;
 				}
 			}

+ 6 - 2
examples/svgModuleGroupShape.php

@@ -56,7 +56,7 @@ class GroupShapeSVGQRCodeOutput extends QRMarkupSVG{
 				// collect the modules per $M_TYPE
 				$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
 
-				if(!empty($module)){
+				if($module !== null){
 					$paths[$M_TYPE_LAYER][] = $module;
 				}
 			}
@@ -68,7 +68,7 @@ class GroupShapeSVGQRCodeOutput extends QRMarkupSVG{
 		return $paths;
 	}
 
-	protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string{
+	protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string|null{
 		$bits     = $this->matrix->checkNeighbours($x, $y, null);
 		$check    = fn(int $all, int $any = 0):bool => ($bits & ($all | (~$any & 0xff))) === $all;
 
@@ -76,6 +76,10 @@ class GroupShapeSVGQRCodeOutput extends QRMarkupSVG{
 			? $this->darkModule($check, $this->options->inverseMelt)
 			: $this->lightModule($check, $this->options->inverseMelt);
 
+		if($template === ''){
+			return null;
+		}
+
 		$r = $this->options->meltRadius;
 
 		return sprintf($template, $x, $y, $r, (1 - $r), (1 - 2 * $r));

+ 1 - 1
examples/svgRandomColoredDots.php

@@ -65,7 +65,7 @@ class RandomDotsSVGOutput extends QRMarkupSVG{
 				// collect the modules per $M_TYPE
 				$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
 
-				if(!empty($module)){
+				if($module !== null){
 					$paths[$M_TYPE_LAYER][] = $module;
 				}
 			}

+ 2 - 2
examples/svgRoundQuietzone.php

@@ -53,7 +53,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
 		// start SVG output
 		$svg = $this->header();
 
-		if(!empty($this->options->svgDefs)){
+		if($this->options->svgDefs !== ''){
 			$svg .= sprintf('<defs>%1$s%2$s</defs>%2$s', $this->options->svgDefs, $this->options->eol);
 		}
 
@@ -186,7 +186,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
 				// collect the modules per $M_TYPE
 				$module = $this->moduleTransform($x, $y, $M_TYPE, $M_TYPE_LAYER);
 
-				if(!empty($module)){
+				if($module !== null){
 					$paths[$M_TYPE_LAYER][] = $module;
 				}
 			}