ColorStop
constructor functions (#20066)
# Objective Add `px` and `percent` constructor functions for `ColorStop`.
This commit is contained in:
parent
83305afa66
commit
63dd8b6652
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user