mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-28 11:07:25 +00:00
:octocat: a few more performance improvements
This commit is contained in:
@@ -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
|
||||
);
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user