Introduce `ArcPieShape` for Simplified Arc and Pie Rendering
Summary
This PR introduces several new features related to drawing arcs and pies in the egui ecosystem.
Changes
epaint: IntroduceArcPieShapefor Simplified Arc and Pie Rendering.egui: EnhancePainterwitharcandpieMethods.egui_demo_lib: Added demonstrations forArcPieShape, These demos showcase how to use these new features in a variety of contexts.
Screenshot
Arcs would be great!
This could be implemented with a PathShape::circle_arc constructor instead, which would require a lot less code (which means less code to maintain).
What motivates this addition? Are circular arcs really that common in GUIs?
EDIT: I now remembered that PathShape only supports filling convex polygons, but I rather spend the time fixing that than adding special-case primitives.
Check the circle screenshot here: https://github.com/David-OConnor/plascad
I rolled one based on varphone's work. Good tip on circle_arc! I'll adapt it to use that.
Note that I ended up doing some hacks to get the concave fill to work; the actual line arc is straightforward, but the fill is kind of awk. (Breaking it up into small segments that don't glitch, drawing a circle with the background color with radius of the arc's inner radius over it etc.)
@emilk I concur with your edit. The big/general fix is for filling concave shapes; that would be a bigger win than a specialty arc!
The current tessellator for filled polygons is doing a triangle fan from the first vertex:
https://github.com/micmonay/egui/blob/fdc6658517c794feb194f78b7ecab0d75f3f259b/crates/epaint/src/tessellator.rs#L732-L787
This means that you could probably use PathShape if the first vertex is the center of the filled pie. Of course, that would rely on an implementation detail, but we could codify that if it works.
Makes sense! The issues arise when there's no pie center! (eg a filled arc segment)
What motivates this addition? Are circular arcs really that common in GUIs?
Depends on the use case, but I think gauges, circular progress bars, and (multi layer) pie/donut charts are common enough.
E.g.