ailloli_ui_widgets/primitives/rounded_rect.rs
1//! Direct rounded-rectangle command construction.
2
3use ailloli_ui_core::{Color, Rect};
4use ailloli_ui_runtime::{DrawCmd, DrawRRect};
5
6/// Creates a rounded rectangle command with a logical-pixel corner `radius`.
7///
8/// Rect and radius values are passed through without normalization or clamping.
9///
10/// # Examples
11///
12/// ```
13/// use ailloli_ui_core::{Color, Rect};
14/// use ailloli_ui_runtime::DrawCmd;
15/// use ailloli_ui_widgets::primitives::draw_rounded_rect;
16/// let DrawCmd::RRect(rect) = draw_rounded_rect(Rect::new(0.0, 0.0, 20.0, 10.0), 4.0, Color::WHITE) else { panic!() };
17/// assert_eq!(rect.radius, 4.0);
18/// ```
19pub fn draw_rounded_rect(rect: Rect, radius: f32, color: Color) -> DrawCmd {
20 DrawCmd::RRect(DrawRRect {
21 rect,
22 radius,
23 color,
24 })
25}