From 13ea674432e798df82d6c56a10b2c0a2692ce3d1 Mon Sep 17 00:00:00 2001 From: JercSi Date: Mon, 18 Mar 2024 02:25:33 +0100 Subject: [PATCH] fix: use non-locale aware format for scale and translate (#100) * Non-locale aware of scale and translate * Fix lint warning - too long line --- src/Renderer/Image/SvgImageBackEnd.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Renderer/Image/SvgImageBackEnd.php b/src/Renderer/Image/SvgImageBackEnd.php index 9fb4bcb..227afa7 100644 --- a/src/Renderer/Image/SvgImageBackEnd.php +++ b/src/Renderer/Image/SvgImageBackEnd.php @@ -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; @@ -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]; } @@ -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]; }