Skip to content

Commit

Permalink
fix: use non-locale aware format for scale and translate (#100)
Browse files Browse the repository at this point in the history
* Non-locale aware of scale and translate
* Fix lint warning - too long line
  • Loading branch information
JercSi authored Mar 18, 2024
1 parent a8b22f3 commit 13ea674
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Renderer/Image/SvgImageBackEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
final class SvgImageBackEnd implements ImageBackEndInterface
{
private const PRECISION = 3;
private const SCALE_FORMAT = 'scale(%.' . self::PRECISION . 'F)';
private const TRANSLATE_FORMAT = 'translate(%.' . self::PRECISION . 'F,%.' . self::PRECISION . 'F)';

private ?XMLWriter $xmlWriter;

Expand Down Expand Up @@ -85,7 +87,7 @@ public function scale(float $size) : void
$this->xmlWriter->startElement('g');
$this->xmlWriter->writeAttribute(
'transform',
sprintf('scale(%s)', round($size, self::PRECISION))
sprintf(self::SCALE_FORMAT, round($size, self::PRECISION))
);
++$this->stack[$this->currentStack];
}
Expand All @@ -99,7 +101,7 @@ public function translate(float $x, float $y) : void
$this->xmlWriter->startElement('g');
$this->xmlWriter->writeAttribute(
'transform',
sprintf('translate(%s,%s)', round($x, self::PRECISION), round($y, self::PRECISION))
sprintf(self::TRANSLATE_FORMAT, round($x, self::PRECISION), round($y, self::PRECISION))
);
++$this->stack[$this->currentStack];
}
Expand Down

0 comments on commit 13ea674

Please sign in to comment.