mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
epaint: Introduce ArcPieShape for Simplified Arc and Pie Rendering
Enables straightforward painting of arcs and pies using specified start and end angles.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
color, CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape,
|
||||
QuadraticBezierShape, RectShape, Shape, TextShape,
|
||||
color, ArcPieShape, CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh,
|
||||
PathShape, QuadraticBezierShape, RectShape, Shape, TextShape,
|
||||
};
|
||||
|
||||
/// Remember to handle [`Color32::PLACEHOLDER`] specially!
|
||||
@@ -46,6 +46,31 @@ pub fn adjust_colors(
|
||||
adjust_color_mode(&mut stroke.color, adjust_color);
|
||||
}
|
||||
|
||||
Shape::ArcPie(ArcPieShape {
|
||||
center: _,
|
||||
radius: _,
|
||||
start_angle: _,
|
||||
end_angle: _,
|
||||
closed,
|
||||
fill,
|
||||
stroke,
|
||||
}) => {
|
||||
if *closed {
|
||||
adjust_color(fill);
|
||||
}
|
||||
match &stroke.color {
|
||||
color::ColorMode::Solid(mut col) => adjust_color(&mut col),
|
||||
color::ColorMode::UV(callback) => {
|
||||
let callback = callback.clone();
|
||||
stroke.color = color::ColorMode::UV(Arc::new(Box::new(move |rect, pos| {
|
||||
let mut col = callback(rect, pos);
|
||||
adjust_color(&mut col);
|
||||
col
|
||||
})));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Shape::Circle(CircleShape {
|
||||
center: _,
|
||||
radius: _,
|
||||
|
||||
Reference in New Issue
Block a user