From f01e0ba60b5cbc41d864a6b67e28f33e8138e535 Mon Sep 17 00:00:00 2001 From: Rodrigo Vilar Date: Sun, 25 Sep 2022 07:50:28 +0200 Subject: [PATCH] fix svg arc --- src/svgcontext.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/svgcontext.ts b/src/svgcontext.ts index 90afd3d9eb..9a3da8d387 100644 --- a/src/svgcontext.ts +++ b/src/svgcontext.ts @@ -442,12 +442,14 @@ export class SVGContext extends RenderContext { const x0 = x + radius * Math.cos(startAngle); const y0 = y + radius * Math.sin(startAngle); - // Handle the edge case where arc length is greater than or equal to - // the circle's circumference: - // https://html.spec.whatwg.org/multipage/canvas.html#ellipse-method-steps + // svg behavior different from canvas. Don't normalize angles if + // we are drawing a circle because they both normalize to 0 + const tmpStartTest = normalizeAngle(startAngle); + const tmpEndTest = normalizeAngle(endAngle); if ( (!counterclockwise && endAngle - startAngle >= TWO_PI) || - (counterclockwise && startAngle - endAngle >= TWO_PI) + (counterclockwise && startAngle - endAngle >= TWO_PI) || + tmpStartTest === tmpEndTest ) { const x1 = x + radius * Math.cos(startAngle + Math.PI); const y1 = y + radius * Math.sin(startAngle + Math.PI); @@ -461,9 +463,8 @@ export class SVGContext extends RenderContext { const x1 = x + radius * Math.cos(endAngle); const y1 = y + radius * Math.sin(endAngle); - startAngle = normalizeAngle(startAngle); - endAngle = normalizeAngle(endAngle); - + startAngle = tmpStartTest; + endAngle = tmpEndTest; let large: boolean; if (Math.abs(endAngle - startAngle) < Math.PI) { large = counterclockwise;