diff --git a/src/Output/QRGdImage.php b/src/Output/QRGdImage.php index 1b376bfe0..e7d9ed734 100644 --- a/src/Output/QRGdImage.php +++ b/src/Output/QRGdImage.php @@ -301,8 +301,8 @@ class QRGdImage extends QROutputAbstract{ $this->image, (($x * $this->scale) + intdiv($this->scale, 2)), (($y * $this->scale) + intdiv($this->scale, 2)), - (int)(2 * $this->circleRadius * $this->scale), - (int)(2 * $this->circleRadius * $this->scale), + (int)($this->circleDiameter * $this->scale), + (int)($this->circleDiameter * $this->scale), $color ); diff --git a/src/Output/QRMarkupSVG.php b/src/Output/QRMarkupSVG.php index c5dcba4f9..5be7cb13b 100644 --- a/src/Output/QRMarkupSVG.php +++ b/src/Output/QRMarkupSVG.php @@ -180,19 +180,16 @@ class QRMarkupSVG extends QRMarkup{ } if($this->drawCircularModules && !$this->matrix->checkTypeIn($x, $y, $this->keepAsSquare)){ - $r = $this->circleRadius; - - return sprintf( - 'M%1$s %2$s a%3$s %3$s 0 1 0 %4$s 0 a%3$s %3$s 0 1 0 -%4$s 0Z', - ($x + 0.5 - $r), - ($y + 0.5), - $r, - ($r * 2) - ); + // string interpolation: ugly and fast + $ix = ($x + 0.5 - $this->circleRadius); + $iy = ($y + 0.5); + // phpcs:ignore + return "M$ix $iy a$this->circleRadius $this->circleRadius 0 1 0 $this->circleDiameter 0 a$this->circleRadius $this->circleRadius 0 1 0 -$this->circleDiameter 0Z"; } - return sprintf('M%1$s %2$s h1 v1 h-1Z', $x, $y); + // phpcs:ignore + return "M$x $y h1 v1 h-1Z"; } } diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php index 133bc843d..d9a37689c 100644 --- a/src/Output/QROutputAbstract.php +++ b/src/Output/QROutputAbstract.php @@ -63,6 +63,7 @@ abstract class QROutputAbstract implements QROutputInterface{ protected array $keepAsSquare; /** @see \chillerlan\QRCode\QROptions::$circleRadius */ protected float $circleRadius; + protected float $circleDiameter; /** * QROutputAbstract constructor. @@ -102,6 +103,7 @@ abstract class QROutputAbstract implements QROutputInterface{ $this->{$property} = $this->options->{$property}; } + $this->circleDiameter = ($this->circleRadius * 2); } /**