Adding tests for Path#quadraticCurveTo
This commit is contained in:
parent
354b65b623
commit
d6cdad7ec3
@ -88,14 +88,16 @@ class Path {
|
||||
relative = relative === undefined ? this.relative : relative;
|
||||
if (cx === undefined || cy === undefined) {
|
||||
const command = relative ? 't' : 'T';
|
||||
this.pathParts.push(`${command} ${x},${y}`);
|
||||
this.pathParts.push(`${command}${x},${y}`);
|
||||
} else {
|
||||
const command = relative ? 'q' : 'Q';
|
||||
this.pathParts.push(`${command}${cx},${cy} ${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;
|
||||
}
|
||||
|
@ -24,7 +24,12 @@ describe('Path', () => {
|
||||
[ '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' ]
|
||||
[ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 's10,11 15,16' ],
|
||||
// quadraticCurveTo
|
||||
[ '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' ]
|
||||
].forEach(([ cmd, args, str ], i) => (
|
||||
test(`case #${ i }`, () => {
|
||||
const path = new Path();
|
||||
|
Loading…
Reference in New Issue
Block a user