-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #945 from edemaine/pointarray-transform
Add PointArray.transform by analogy to Point.transform
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
describe('PointArray', function() { | ||
const squareString = '0,0 1,0 1,1 0,1'; | ||
const square = new SVG.PointArray(squareString) | ||
|
||
describe('toString()', function() { | ||
it('round trips with string', () => { | ||
expect(square.toString()).toEqual(squareString) | ||
}) | ||
}) | ||
|
||
describe('transform()', function() { | ||
it('translates correctly', () => { | ||
const translation = new SVG.Matrix().translate(2,1) | ||
const newSquare = square.transform(translation) | ||
expect(newSquare.toString()).toEqual('2,1 3,1 3,2 2,2') | ||
}) | ||
|
||
it('transforms like Point', () => { | ||
const matrix = new SVG.Matrix(1, 2, 3, 4, 5, 6) | ||
const newSquare = square.transform(matrix) | ||
for (let i = 0; i < square.length; i++) { | ||
const squarePoint = new SVG.Point(square[i]) | ||
const newSquarePoint = new SVG.Point(newSquare[i]) | ||
expect(squarePoint.transform(matrix)).toEqual(newSquarePoint) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters