diff options
author | Erik Demaine <edemaine@mit.edu> | 2018-12-13 11:09:20 -0500 |
---|---|---|
committer | Erik Demaine <edemaine@mit.edu> | 2018-12-13 11:09:20 -0500 |
commit | 62a248f7add66c3dc4e70d26b3f05e4e58455c12 (patch) | |
tree | f5eaf350e1f06c7f16b214cf1466d04fcad06328 | |
parent | 33e82b796e7870a9523b6e9653877a2613f8f7a2 (diff) | |
download | svg.js-62a248f7add66c3dc4e70d26b3f05e4e58455c12.tar.gz svg.js-62a248f7add66c3dc4e70d26b3f05e4e58455c12.zip |
Add PointArray.transform by analogy to Point.transform
-rw-r--r-- | src/types/PointArray.js | 14 |
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() |