aboutsummaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorErik Demaine <edemaine@mit.edu>2018-12-13 11:09:20 -0500
committerErik Demaine <edemaine@mit.edu>2018-12-13 11:09:20 -0500
commit62a248f7add66c3dc4e70d26b3f05e4e58455c12 (patch)
treef5eaf350e1f06c7f16b214cf1466d04fcad06328 /src/types
parent33e82b796e7870a9523b6e9653877a2613f8f7a2 (diff)
downloadsvg.js-62a248f7add66c3dc4e70d26b3f05e4e58455c12.tar.gz
svg.js-62a248f7add66c3dc4e70d26b3f05e4e58455c12.zip
Add PointArray.transform by analogy to Point.transform
Diffstat (limited to 'src/types')
-rw-r--r--src/types/PointArray.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/types/PointArray.js b/src/types/PointArray.js
index 9e7406d..6488c29 100644
--- a/src/types/PointArray.js
+++ b/src/types/PointArray.js
@@ -71,6 +71,20 @@ extend(PointArray, {
return points
},
+ // transform points with matrix (similar to Point.transform)
+ transform (m) {
+ let points = []
+
+ for (let point of this) {
+ // Perform the matrix multiplication
+ points.push([m.a * point.x + m.c * point.y + m.e,
+ m.b * point.x + m.d * point.y + m.f])
+ }
+
+ // Return the required point
+ return new PointArray(points)
+ }
+
// Move point string
move (x, y) {
var box = this.bbox()