diff --git a/crates/bevy_ui/src/gradients.rs b/crates/bevy_ui/src/gradients.rs index 7086b37416..87b7afc581 100644 --- a/crates/bevy_ui/src/gradients.rs +++ b/crates/bevy_ui/src/gradients.rs @@ -44,6 +44,24 @@ impl ColorStop { } } + /// A color stop with its position in logical pixels. + pub fn px(color: impl Into, px: f32) -> Self { + Self { + color: color.into(), + point: Val::Px(px), + hint: 0.5, + } + } + + /// A color stop with a percentage position. + pub fn percent(color: impl Into, percent: f32) -> Self { + Self { + color: color.into(), + point: Val::Percent(percent), + hint: 0.5, + } + } + // Set the interpolation midpoint between this and the following stop pub fn with_hint(mut self, hint: f32) -> Self { self.hint = hint;