diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-12-14 22:35:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-14 22:35:45 +0100 |
commit | f2eb24610bb607b92d786dc77857871302cea49a (patch) | |
tree | 143cbf007c0039e4cae4a8c89fa7ae86a65f4dff /src | |
parent | 33e82b796e7870a9523b6e9653877a2613f8f7a2 (diff) | |
parent | 79554009233065d40117690158d99161e31cb5dc (diff) | |
download | svg.js-f2eb24610bb607b92d786dc77857871302cea49a.tar.gz svg.js-f2eb24610bb607b92d786dc77857871302cea49a.zip |
Merge pull request #945 from edemaine/pointarray-transform
Add PointArray.transform by analogy to Point.transform
Diffstat (limited to 'src')
-rw-r--r-- | src/types/PointArray.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/types/PointArray.js b/src/types/PointArray.js index 9e7406d..2246bbd 100644 --- a/src/types/PointArray.js +++ b/src/types/PointArray.js @@ -71,6 +71,23 @@ extend(PointArray, { return points }, + // transform points with matrix (similar to Point.transform) + transform (m) { + const points = [] + + for (let i = 0; i < this.length; i++) { + const point = this[i] + // Perform the matrix multiplication + points.push([ + m.a * point[0] + m.c * point[1] + m.e, + m.b * point[0] + m.d * point[1] + m.f + ]) + } + + // Return the required point + return new PointArray(points) + }, + // Move point string move (x, y) { var box = this.bbox() |