Skip to content

Commit 4d2cca7

Browse files
author
naitsirch
committed
Extended rotate transformation to support rotation about another point
SVG supports the rotation of an element about another point (see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#Rotate). php-svg-lib did not support this before. So I added this feature. I got the idea for the implementation from https://github.com/deeplook/svglib/. Credits to @deeplook.
1 parent ccc46ef commit 4d2cca7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Svg/Tag/AbstractTag.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ protected function applyTransform($attributes)
166166
break;
167167

168168
case "rotate":
169-
$surface->rotate($t[1]);
169+
if (isset($t[2]) || isset($t[3])) {
170+
$surface->translate($t[2], $t[3]);
171+
$surface->rotate($t[1]);
172+
$surface->translate(-$t[2], -$t[3]);
173+
} else {
174+
$surface->rotate($t[1]);
175+
}
170176
break;
171177

172178
case "skewX":

0 commit comments

Comments
 (0)