1
0
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:
Varphone Wong
2024-07-17 16:41:26 +08:00
parent 8cfab39635
commit 4179e48e7a
7 changed files with 353 additions and 10 deletions

View File

@@ -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: _,