Skip to content

Support stand-alone Path objects in Canvas#4163

Open
corranwebster wants to merge 63 commits into
beeware:mainfrom
corranwebster:canvas-backend-path
Open

Support stand-alone Path objects in Canvas#4163
corranwebster wants to merge 63 commits into
beeware:mainfrom
corranwebster:canvas-backend-path

Conversation

@corranwebster
Copy link
Copy Markdown
Contributor

@corranwebster corranwebster commented Feb 4, 2026

This provides an implementation of Canvas paths as stand-alone objects, generally following the HTML Canvas design. In particular, this creates a top-level Path2D object with path creation methods which can be used independently of any particular Canvas and re-used multiple times as needed. This has particular use when working with things like plot markers. As with the HTML canvas, paths are rendered by passing them as arguments to the fill or stroke methods.

In terms of implementation, paths wrap the backend's notion of a path as an implementation object, and the front-end "compiles" the Path2D to a backend path object, so drawing paths repeatedly is very efficient. The Path2D implementations are potentially reusable by third-party widgets built using the Canvas implementation (eg. plotting libraries).

The PR provides a simple example as part of the canvas demo.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@corranwebster corranwebster mentioned this pull request Feb 5, 2026
7 tasks
@corranwebster
Copy link
Copy Markdown
Contributor Author

Looks like a segfault on macOS Intel machines. I can replicate on an old Intel Mac on macOS Sequoia. It looks like it is an issue with CGPathAddArc in Path2d.ellipse when counterclockwise is True. Works fine on Arm machines.

@corranwebster
Copy link
Copy Markdown
Contributor Author

It's been a bit of a journey, but I think this is ready for review.

@corranwebster corranwebster marked this pull request as ready for review May 10, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants