Rename transparentize to scale_alpha
This commit is contained in:
parent
288025f514
commit
3e99f39a86
4 changed files with 24 additions and 18 deletions
|
|
@ -12,17 +12,13 @@ pub enum Gradient {
|
|||
}
|
||||
|
||||
impl Gradient {
|
||||
/// Adjust the opacity of the gradient by a multiplier applied to each color stop.
|
||||
pub fn transparentize(mut self, factor: f32) -> Self {
|
||||
match &mut self {
|
||||
/// Scales the alpha channel of the [`Gradient`] by the given factor.
|
||||
pub fn scale_alpha(self, factor: f32) -> Self {
|
||||
match self {
|
||||
Gradient::Linear(linear) => {
|
||||
for stop in linear.stops.iter_mut().flatten() {
|
||||
stop.color.a *= factor;
|
||||
}
|
||||
Gradient::Linear(linear.scale_alpha(factor))
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,4 +96,14 @@ impl Linear {
|
|||
|
||||
self
|
||||
}
|
||||
|
||||
/// Scales the alpha channel of the [`Linear`] gradient by the given
|
||||
/// factor.
|
||||
pub fn scale_alpha(mut self, factor: f32) -> Self {
|
||||
for stop in self.stops.iter_mut().flatten() {
|
||||
stop.color.a *= factor;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue