Skip to content

Commit

Permalink
fix(svg): parse sweepFlag to counterclockwise error
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Dec 21, 2024
1 parent 5f1e943 commit a7a596d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/svg/parseArcCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function svgAngle(ux: number, uy: number, vx: number, vy: number): number {
}

/**
* https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
* https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
* @link https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
* @link https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
* From
* rx ry x-axis-rotation large-arc-flag sweep-flag x y
* To
Expand Down Expand Up @@ -70,5 +70,5 @@ export function parseArcCommand(
// Step 4: Compute θ1 and Δθ
const theta = svgAngle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry)
const delta = svgAngle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry) % (Math.PI * 2)
path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 1)
path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 0)
}

0 comments on commit a7a596d

Please sign in to comment.