-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Arc and Pie Drawing and Plotting Features #4424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing I saw was using Stroke instead of PathStroke for lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing that change! I'm a bit tired right now so I'll look over everything else when I get the chance. (feel free to poke me)
let stroke_color = match stroke.color { | ||
ColorMode::Solid(color) => color, | ||
ColorMode::UV(callback) => { | ||
// We can't use the callback here, so we just use the center of the circle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this behavior should be documented somewhere? I'm also not fully sure if you can't use the callback here, could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire pie is rendered as a circle, but CircleShape
is not compatible with PathStroke
.
As a workaround, I use a callback to obtain the center color from PathStroke
.
This issue should be addressed once CircleShape
supports PathStroke
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand. Thanks for elaborating!
Im hoping that the underlying ColorMode
will be used for more shapes in the future, but for the time being it is only for paths. If you want, I can look into opening a PR to support PathStroke
for more shapes
This commit introduces a new shape to the `epaint` library, named `ArcPieShape`. This shape represents an arc or a pie slice that can be rendered with specified radius, angle, fill, and stroke properties. It's useful for rendering pie charts, donut charts, and other circular data visualizations.
This commit adds `Painter::{arc, pie}` methods to `egui::Painter`. These methods simplify the process of drawing arcs and pies.
This commit introduces three new plot types to the `egui_plot` library: `ArcLine`, `Pie`, and `PieChart`. - `ArcLine` is a plot that renders a simple arc line. - `Pie` is a plot that renders a single pie slice. - `PieChart` is a plot that renders a pie chart with data and labels.
…PieChart` This commit adds demonstrations for `ArcPieShape`, `ArcLine`, `Pie`, and `PieChart` to the `egui_demo_lib` library. These demos showcase how to use these new features in a variety of contexts.
…Pie(_)` with rayon
3cb39f1
to
af274cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything LGTM, I did have some performance concerns but eyeballing the frame render times in the standalone demo didn't justify benchmarks. Playing around with the demo you included, I wasn't able to break it visually, and I do think you already account for start and end angles that result in a full circle.
Take a look to a bezier curve arc approximation methods, it could be faster(may be) https://docs.rs/bezier-nd/latest/bezier_nd/struct.Bezier.html#method.arc Example: https://github.com/enomado/smitters/blob/main/src/egui.rs#L6 |
It could also be more accurate, if you'd like an example, I have a duplicate PR: #4426 Side note: I probably should have caught this in my review. Sorry! |
This will hopefully speed up its development by having more reviewers and maintainers. Please re-open this PR at https://github.com/emilk/egui_plot/pulls See also: |
@emilk, I'd categorize this as an epaint feature request, or at least a part of it |
Summary
This PR introduces several new features related to drawing and plotting arcs and pies in the
egui
ecosystem.Changes
epaint
: IntroducedArcPieShape
, a new shape that represents an arc or a pie slice with specified radius, angle, fill, and stroke properties.egui
: AddedPainter::{arc, pie}
methods, which simplify the process of drawing arcs and pies.egui_plot
: Introduced three new plot types:ArcLine
,Pie
, andPieChart
.ArcLine
renders a simple arc line,Pie
renders a single pie slice, andPieChart
renders a pie chart with data and labels.egui_demo_lib
: Added demonstrations forArcPieShape
,ArcLine
,Pie
, andPieChart
. These demos showcase how to use these new features in a variety of contexts.Impact
These changes enhance the capabilities of the
egui
ecosystem by providing users with more options for drawing and plotting.The new demos also serve as valuable examples for users to learn from.
screencast-egui_demo_app-2024-04-27.webm