1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Add epaint::RoundedRect primitive (#8440)

This commit is contained in:
Emil Ernerfeldt
2026-08-21 01:33:54 -07:00
committed by GitHub
parent 00dc6e814b
commit f5c9373e26
4 changed files with 173 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
use crate::{Color32, CornerRadius, MarginF32, Rect, RectShape, Vec2};
use crate::{Color32, CornerRadius, MarginF32, Rect, RectShape, RoundedRect, Vec2};
/// The color and fuzziness of a fuzzy shape.
///
@@ -56,10 +56,12 @@ impl Shadow {
} = *self;
let [offset_x, offset_y] = offset;
let rect = rect
.translate(Vec2::new(offset_x as _, offset_y as _))
.expand(spread as _);
let corner_radius = corner_radius.into() + CornerRadius::from(spread);
let (rect, corner_radius) = RoundedRect::new(
rect.translate(Vec2::new(offset_x as _, offset_y as _)),
corner_radius.into(),
)
.expand(f32::from(spread))
.into_parts();
RectShape::filled(rect, corner_radius, color).with_blur_width(blur as _)
}