Adding tests for cubicCurveTo

This commit is contained in:
Jeff Avallone 2018-02-18 15:58:23 -05:00
parent 9716e166df
commit 354b65b623
2 changed files with 9 additions and 2 deletions

View File

@ -76,8 +76,10 @@ class Path {
this.pathParts.push(`${command}${cx1},${cy1} ${cx2},${cy2} ${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

@ -20,6 +20,11 @@ describe('Path', () => {
[ 'lineTo', { x: 5, relative: true }, 'h5' ],
[ 'lineTo', { y: 1, relative: true }, 'v1' ],
[ 'lineTo', { relative: true }, '' ],
// cubicCurveTo
[ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16 }, 'C5,6 10,11 15,16' ],
[ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16 }, 'S10,11 15,16' ],
[ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 'c5,6 10,11 15,16' ],
[ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 's10,11 15,16' ]
].forEach(([ cmd, args, str ], i) => (
test(`case #${ i }`, () => {
const path = new Path();