Skip to content

Commit 788bb77

Browse files
JercSiDASPRiD
authored andcommitted
fix: use non-locale aware format for scale and translate (#100)
* Non-locale aware of scale and translate * Fix lint warning - too long line
1 parent 2f1e117 commit 788bb77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Renderer/Image/SvgImageBackEnd.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
final class SvgImageBackEnd implements ImageBackEndInterface
2020
{
2121
private const PRECISION = 3;
22+
private const SCALE_FORMAT = 'scale(%.' . self::PRECISION . 'F)';
23+
private const TRANSLATE_FORMAT = 'translate(%.' . self::PRECISION . 'F,%.' . self::PRECISION . 'F)';
2224

2325
private ?XMLWriter $xmlWriter;
2426

@@ -85,7 +87,7 @@ public function scale(float $size) : void
8587
$this->xmlWriter->startElement('g');
8688
$this->xmlWriter->writeAttribute(
8789
'transform',
88-
sprintf('scale(%s)', round($size, self::PRECISION))
90+
sprintf(self::SCALE_FORMAT, round($size, self::PRECISION))
8991
);
9092
++$this->stack[$this->currentStack];
9193
}
@@ -99,7 +101,7 @@ public function translate(float $x, float $y) : void
99101
$this->xmlWriter->startElement('g');
100102
$this->xmlWriter->writeAttribute(
101103
'transform',
102-
sprintf('translate(%s,%s)', round($x, self::PRECISION), round($y, self::PRECISION))
104+
sprintf(self::TRANSLATE_FORMAT, round($x, self::PRECISION), round($y, self::PRECISION))
103105
);
104106
++$this->stack[$this->currentStack];
105107
}

0 commit comments

Comments
 (0)