Added px and percent constructor functions for ColorStop

This commit is contained in:
ickshonpe 2025-07-09 21:27:47 +01:00
parent 09ccedd244
commit 83ee4c9066

View File

@ -44,6 +44,24 @@ impl ColorStop {
}
}
/// A color stop with its position in logical pixels.
pub fn px(color: impl Into<Color>, 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<Color>, 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;