Open jbuckmccready opened 3 years ago
I touched on this in https://github.com/emilk/egui/pull/471 but haven't gotten a response yet:
I also have an implementation of the ear-clipping algorithm lying around that can be used to tessellate non-convex polygons. It's relatively few lines of code, but it's not the most efficient algorithm with O(n²) time complexity. I could add this to the plotting library, but maybe it's something for egui in general?
More efficient algorithms are exponentially more difficult to implement, so going with lyon
's faster algorithms may be a good option as well.
The problem with lyon
is that it doesn't support feathering (what epaint
uses to smooth edges) AFAIK. Creating a convex filling algorithm that also supports feathering seems like a big task, but I agree it would be very nice to have.
There is another alternative: turn off feathering and turn on MSAA to get smoother edges. This is already supported on eframe
native, and it could be added to egui_web
too. Then we could just use lyon
directly to produce epaint::Mesh
es.
Maybe we could decompose one concave polygon into some convex polygons, and store them. And I can implement it if possible.
Just came across this same issue - has any work towards this been done? My use case in particular is filling the area underneath a line plot.
I'm currently implementing a workaround but ideally this would be something that egui supports natively - let me know if there's anything I can do to help.
From what I can tell by reading the docs/playing with the code currently only convex polygon filling is supported. Is supporting concave (or possibly even complex polygons) a future goal for egui or is that outside the scope of the project? I think something like Lyon could be used for tessellation, and I saw the Mesh type so I can probably combine the two, but I didn't see support for the mesh type with the plot widget.
I really like the egui API in general and the recent improvements to the plot widget are very nice. I would like to be able to add concave polygons to plots. I am currently using wasm + html/js to create the cavalier contours web demo (web demo link here), but the egui API looks very nice and keeps everything in Rust.
I looked briefly at the code and I see the plot widget structs use the shape types/rendering under the hood. One option I see is just adding generic mesh object support to the plot widget (kind of a low level interface for the widget), another possibility is building out support for concave polygons in general, any thoughts/plans already around this?