Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bezierToQuadratic() {
if (!this._bezier) {
return this;
}
const path = new Path();
let x = 0;
let y = 0;
for (const c of this.commands) {
if (c.command === 'bezierCurveTo') {
const quads = cubic2quad(x, y, ...c.args, 0.1);
for (let i = 2; i < quads.length; i += 4) {
path.quadraticCurveTo(quads[i], quads[i + 1], quads[i + 2], quads[i + 3]);
}
} else {
path[c.command](...c.args);
x = c.args[c.args.length - 2] || 0;
y = c.args[c.args.length - 1] || 0;
}
}
return path;
}