Adding tests for Path#arcTo
This commit is contained in:
parent
d6cdad7ec3
commit
ef33cdab04
@ -106,10 +106,12 @@ class Path {
|
|||||||
relative = relative === undefined ? this.relative : relative;
|
relative = relative === undefined ? this.relative : relative;
|
||||||
const command = relative ? 'a' : 'A';
|
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 = {
|
||||||
this.currentPosition.y = relative ? this.currentPosition.y + y : y;
|
x: relative ? this.currentPosition.x + x : x,
|
||||||
|
y: relative ? this.currentPosition.y + y : y
|
||||||
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,10 @@ describe('Path', () => {
|
|||||||
[ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11 }, 'Q5,6 10,11' ],
|
[ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11 }, 'Q5,6 10,11' ],
|
||||||
[ 'quadraticCurveTo', { x: 10, y: 11 }, 'T10,11' ],
|
[ 'quadraticCurveTo', { x: 10, y: 11 }, 'T10,11' ],
|
||||||
[ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11, relative: true }, 'q5,6 10,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) => (
|
].forEach(([ cmd, args, str ], i) => (
|
||||||
test(`case #${ i }`, () => {
|
test(`case #${ i }`, () => {
|
||||||
const path = new Path();
|
const path = new Path();
|
||||||
|
Loading…
Reference in New Issue
Block a user