Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-locale aware of scale and translate #100

Merged
merged 2 commits into from Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Renderer/Image/SvgImageBackEnd.php
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)';

/**
* @var XMLWriter|null
Expand Down Expand Up @@ -97,7 +99,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 @@ -111,7 +113,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