From 432cb43453084c7a0f2bb87b81cae258624ec3eb Mon Sep 17 00:00:00 2001 From: Jason Sturges Date: Sat, 19 Dec 2020 16:41:44 -0600 Subject: [PATCH] fix(): Util `fromArcToBeziers()` API update (#6733) --- src/util/path.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/util/path.js b/src/util/path.js index 5e1e2429e30..319e153cca1 100644 --- a/src/util/path.js +++ b/src/util/path.js @@ -115,7 +115,7 @@ * @param {Number} y1 * @param {Number} x2 secondo control point * @param {Number} y2 - * @param {Number} x3 end of beizer + * @param {Number} x3 end of bezier * @param {Number} y3 */ // taken from http://jsbin.com/ivomiq/56/edit no credits available for that. @@ -203,12 +203,12 @@ } /** - * Converts arc to a bunch of beizer curves + * Converts arc to a bunch of bezier curves * @param {Number} fx starting point x * @param {Number} fy starting point y * @param {Array} coords Arc command */ - function fromArcToBeizers(fx, fy, coords) { + function fromArcToBeziers(fx, fy, coords) { var rx = coords[1], ry = coords[2], rot = coords[3], @@ -377,7 +377,7 @@ // falls through case 'A': converted = true; - destinationPath = destinationPath.concat(fromArcToBeizers(x, y, current)); + destinationPath = destinationPath.concat(fromArcToBeziers(x, y, current)); x = current[6]; y = current[7]; break; @@ -692,16 +692,22 @@ */ function drawArc(ctx, fx, fy, coords) { coords = coords.slice(0).unshift('X'); // command A or a does not matter - var beizers = fromArcToBeizers(fx, fy, coords); - beizers.forEach(function(beizer) { - ctx.bezierCurveTo.apply(ctx, beizer.slice(1)); + var beziers = fromArcToBeziers(fx, fy, coords); + beziers.forEach(function(bezier) { + ctx.bezierCurveTo.apply(ctx, bezier.slice(1)); }); }; fabric.util.parsePath = parsePath; fabric.util.makePathSimpler = makePathSimpler; fabric.util.getPathSegmentsInfo = getPathSegmentsInfo; - fabric.util.fromArcToBeizers = fromArcToBeizers; + fabric.util.fromArcToBeziers = fromArcToBeziers; + /** + * Typo of `fromArcToBeziers` kept for not breaking the api once corrected. + * Will be removed in fabric 5.0 + * @deprecated + */ + fabric.util.fromArcToBeizers = fromArcToBeziers; fabric.util.getBoundsOfCurve = getBoundsOfCurve; fabric.util.getPointOnPath = getPointOnPath; // kept because we do not want to make breaking changes.