Skip to content

canvas: arcTo draws the long arc (three quarters of the circle) instead of the corner #97

Closed

Description

@HEOJUNFO

CanvasRenderingContext2D.arcTo() draws the arc the long way round. For a right-angle corner it draws three quarters of the circle through the far side instead of the quarter arc between the two tangent points.

Where: sdk/ui/src/canvas/context.ts, last line of arcTo:

P.ellipse(cx, cy, r, r, 0, a0, a1, cross < 0);

The last argument is ccw, and it is inverted.

Example

c.beginPath();
c.moveTo(0, 0);
c.arcTo(10, 0, 10, 10, 5);

Tangent points are (5, 0) and (10, 5), centre (5, 5), so a0 = -π/2 and a1 = 0. The short arc runs clockwise, but cross is -100 here, so ccw is true and Path.ellipse turns the sweep into -3π/2: three cubics instead of one. The mirrored corner (arcTo(10, 0, 10, -10, 5), cross = 100) goes wrong the other way. roundRect in the same file builds the same corners with ellipse(..., false) and is fine.

Expected: one quarter arc from (5, 0) to (10, 5), as a browser draws it.

How I checked: by reading the code at 7099bb9 and with a bun test on the SDK's canvas context that counts the cubics in the path (3 on main, 1 with cross > 0). I have not compared a rendered frame against a browser. sdk/ui/parity/cases/p15-media/canvas-paths.tsx calls arcTo(460, 100, 460, 180, 20), so that case should show it.

The fix is that one character plus a test file (sdk/ui/test/canvas-arcto.test.ts). I have it on a branch and can send it as a PR if you'd like one.

Activity

  1. shinyobjectz commented on Nov 12, 2026

    @shinyobjectz
    Owner

    Fixed on main in c89de2a, exactly your one character, with sdk/ui/test/canvas-arcto.test.ts checking both turning directions and a four-corner rounded rectangle by their cubics. Thanks for the precise report; since the fix was already written up here, I landed it directly rather than wait on a PR, so the credit is in the commit message. Closing.

  2. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions