Adding tests for Path#arcTo

This commit is contained in:
Jeff Avallone 2018-02-18 16:03:46 -05:00
parent d6cdad7ec3
commit ef33cdab04
2 changed files with 9 additions and 4 deletions

View File

@ -106,10 +106,12 @@ class Path {
relative = relative === undefined ? this.relative : relative;
const command = relative ? 'a' : 'A';
this.pathParts.push(`${command}${rx},${ry} ${rotation} ${arc} ${sweep},${x},${y}`);
this.pathParts.push(`${command}${rx},${ry} ${rotation} ${arc} ${sweep} ${x},${y}`);
this.currentPosition.x = relative ? this.currentPosition.x + x : x;
this.currentPosition.y = relative ? this.currentPosition.y + y : y;
this.currentPosition = {
x: relative ? this.currentPosition.x + x : x,
y: relative ? this.currentPosition.y + y : y
};
return this;
}

View File

@ -29,7 +29,10 @@ describe('Path', () => {
[ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11 }, 'Q5,6 10,11' ],
[ 'quadraticCurveTo', { x: 10, y: 11 }, 'T10,11' ],
[ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11, relative: true }, 'q5,6 10,11' ],
[ 'quadraticCurveTo', { x: 10, y: 11, relative: true }, 't10,11' ]
[ 'quadraticCurveTo', { x: 10, y: 11, relative: true }, 't10,11' ],
// arcTo
[ 'arcTo', { rx: 5, ry: 6, rotation: 1, arc: 0, sweep: 0, x: 10, y: 11 }, 'A5,6 1 0 0 10,11' ],
[ 'arcTo', { rx: 5, ry: 6, rotation: 1, arc: 0, sweep: 0, x: 10, y: 11, relative: true }, 'a5,6 1 0 0 10,11' ]
].forEach(([ cmd, args, str ], i) => (
test(`case #${ i }`, () => {
const path = new Path();