summaryrefslogtreecommitdiffstats
path: root/core/src/gradient.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-03-08 14:00:28 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-08 14:00:28 +0100
commitedf7d7ca7593f660f4b15f154257471c26df87de (patch)
tree7cee3cbfbeb2ae5145f1bf6087b61fce4cbed8c9 /core/src/gradient.rs
parent2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859 (diff)
parent8919f2593e39f76b273513e959fa6d5ffb78fde2 (diff)
downloadiced-edf7d7ca7593f660f4b15f154257471c26df87de.tar.gz
iced-edf7d7ca7593f660f4b15f154257471c26df87de.tar.bz2
iced-edf7d7ca7593f660f4b15f154257471c26df87de.zip
Merge pull request #2312 from iced-rs/theming-reloaded
Theming reloaded
Diffstat (limited to 'core/src/gradient.rs')
-rw-r--r--core/src/gradient.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/src/gradient.rs b/core/src/gradient.rs
index 4711b044..ccae0bce 100644
--- a/core/src/gradient.rs
+++ b/core/src/gradient.rs
@@ -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 mul_alpha(mut self, alpha_multiplier: 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 *= alpha_multiplier;
- }
+ 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
+ }
}