mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-17 15:31:06 +00:00
:octocat:
This commit is contained in:
@@ -28,6 +28,10 @@ class QRMarkupSVG extends QRMarkup{
|
||||
|
||||
final public const string MIME_TYPE = 'image/svg+xml';
|
||||
|
||||
// micro optimization for circle radius and diameter values in long loops
|
||||
protected float $r;
|
||||
protected float $d;
|
||||
|
||||
/**
|
||||
* @todo: XSS proof
|
||||
*
|
||||
@@ -116,6 +120,9 @@ class QRMarkupSVG extends QRMarkup{
|
||||
* returns one or more SVG <path> elements
|
||||
*/
|
||||
protected function paths():string{
|
||||
$this->r = $this->options->circleRadius;
|
||||
$this->d = $this->r * 2;
|
||||
|
||||
$paths = $this->collectModules();
|
||||
$svg = [];
|
||||
|
||||
@@ -173,13 +180,11 @@ class QRMarkupSVG extends QRMarkup{
|
||||
|
||||
if($this->options->drawCircularModules && !$this->matrix->checkTypeIn($x, $y, $this->options->keepAsSquare)){
|
||||
// string interpolation: ugly and fast
|
||||
$r = $this->options->circleRadius;
|
||||
$d = $r * 2;
|
||||
$ix = ($x + 0.5 - $r);
|
||||
$ix = ($x + 0.5 - $this->r);
|
||||
$iy = ($y + 0.5);
|
||||
|
||||
// phpcs:ignore
|
||||
return "M$ix $iy a$r $r 0 1 0 $d 0 a$r $r 0 1 0 -$d 0Z";
|
||||
return "M$ix $iy a$this->r $this->r 0 1 0 $this->d 0 a$this->r $this->r 0 1 0 -$this->d 0Z";
|
||||
}
|
||||
|
||||
// phpcs:ignore
|
||||
|
||||
@@ -37,6 +37,13 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
*/
|
||||
protected int $length;
|
||||
|
||||
/**
|
||||
* The current module scale value (might have been modified)
|
||||
*
|
||||
* @see \chillerlan\QRCode\QROptions::$scale
|
||||
*/
|
||||
protected int $scale;
|
||||
|
||||
/**
|
||||
* an (optional) array of color values for the several QR matrix parts
|
||||
*
|
||||
@@ -54,13 +61,6 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
*/
|
||||
protected SettingsContainerInterface|QROptions $options;
|
||||
|
||||
/**
|
||||
* The current module scale value (might have been modified)
|
||||
*
|
||||
* @see \chillerlan\QRCode\QROptions::$scale
|
||||
*/
|
||||
protected int $scale;
|
||||
|
||||
/**
|
||||
* QROutputAbstract constructor.
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
/**
|
||||
* Sets/updates the matrix dimensions
|
||||
*
|
||||
* Call this method if you modify the matrix from within your custom module in case the dimensions have been changed
|
||||
* Call this method if you modify the matrix from within your custom output class in case the dimensions have been changed
|
||||
*/
|
||||
protected function setMatrixDimensions():void{
|
||||
$this->moduleCount = $this->matrix->moduleCount;
|
||||
|
||||
@@ -112,7 +112,7 @@ trait QROptionsTrait{
|
||||
}
|
||||
|
||||
/**
|
||||
* Mask Pattern to use (no value in using, mostly for unit testing purposes)
|
||||
* Mask Pattern to use (no value in using, mostly for unit testing purposes, will cause unreadable symbols)
|
||||
*
|
||||
* `0 ... 7` or `MaskPattern::PATTERN_AUTO` (default)
|
||||
*
|
||||
@@ -150,7 +150,7 @@ trait QROptionsTrait{
|
||||
/**
|
||||
* Return the image resource instead of a render if applicable.
|
||||
*
|
||||
* - `QRGdImage`: `resource` (PHP < 8), `GdImage`
|
||||
* - `QRGdImage`: `GdImage`
|
||||
* - `QRImagick`: `Imagick`
|
||||
* - `QRFpdf`: `FPDF`
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user