From c58421ef7a7f5a554e67da3dd5ed8bf54718ccd5 Mon Sep 17 00:00:00 2001 From: Caleb Evans Date: Wed, 29 May 2024 17:47:30 -0700 Subject: [PATCH] Clean up _getConicOffsets function --- src/jcanvas.ts | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/jcanvas.ts b/src/jcanvas.ts index 071dba7..736694f 100644 --- a/src/jcanvas.ts +++ b/src/jcanvas.ts @@ -2893,29 +2893,17 @@ function _getConicY(y: number, radiusY: number, angle: number) { return y + radiusY * sin(angle); } -// Modify the path +// Calculate angles and positioning for arcs/ellipses function _getConicOffsets(params: JCanvasObject, path: JCanvasObject) { - let offsetX: number; - let offsetY: number; - let angleDiff: number; - // Determine offset from dragging - if (params === path) { - offsetX = 0; - offsetY = 0; - } else { - offsetX = params.x; - offsetY = params.y; - } + const offsetX = params === path ? 0 : params.x; + const offsetY = params === path ? 0 : params.y; + // Ensure arrows are pointed correctly for CCW arcs + const angleDiff = path.ccw ? -PI / 180 : PI / 180; const pathX = path.x + offsetX; const pathY = path.y + offsetY; - // Convert default end angle to radians - if (!path.inDegrees && path.end === 360) { - path.end = PI * 2; - } - // Convert angles to radians, then offset to make 0deg due north of arc const pathStartAngle = path.start * params._toRad - PI / 2; const pathEndAngle = @@ -2923,11 +2911,6 @@ function _getConicOffsets(params: JCanvasObject, path: JCanvasObject) { ? PI * 2 : path.end * params._toRad - PI / 2; - // Ensure arrows are pointed correctly for CCW arcs - angleDiff = PI / 180; - if (path.ccw) { - angleDiff *= -1; - } return { pathX, pathY, angleDiff, pathStartAngle, pathEndAngle }; }