From 423af5c07b8de78eee24e08541569f852e261b33 Mon Sep 17 00:00:00 2001 From: Varphone Wong Date: Wed, 17 Jul 2024 16:43:24 +0800 Subject: [PATCH] `egui`: Enhance `Painter` with `arc` and `pie` Methods Introduces convenient methods for drawing arcs and pies directly within the UI. --- crates/egui/src/painter.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/egui/src/painter.rs b/crates/egui/src/painter.rs index 22a0a0a9d..fc9cf8d49 100644 --- a/crates/egui/src/painter.rs +++ b/crates/egui/src/painter.rs @@ -370,6 +370,38 @@ impl Painter { self.add(Shape::vline(x, y, stroke)) } + /// Paints an arc line. + pub fn arc( + &self, + center: Pos2, + radius: f32, + start_angle: f32, + end_angle: f32, + stroke: impl Into, + ) -> ShapeIdx { + self.add(Shape::arc(center, radius, start_angle, end_angle, stroke)) + } + + /// Paints a pie slice. + pub fn pie( + &self, + center: Pos2, + radius: f32, + start_angle: f32, + end_angle: f32, + fill: impl Into, + stroke: impl Into, + ) -> ShapeIdx { + self.add(Shape::pie( + center, + radius, + start_angle, + end_angle, + fill, + stroke, + )) + } + pub fn circle( &self, center: Pos2,