Introduce dynamic opacity support for Image and Svg
This commit is contained in:
parent
38cf87cb45
commit
fa9e1d96ea
18 changed files with 142 additions and 33 deletions
|
|
@ -30,6 +30,7 @@ where
|
|||
content_fit: ContentFit,
|
||||
class: Theme::Class<'a>,
|
||||
rotation: Rotation,
|
||||
opacity: f32,
|
||||
}
|
||||
|
||||
impl<'a, Theme> Svg<'a, Theme>
|
||||
|
|
@ -45,6 +46,7 @@ where
|
|||
content_fit: ContentFit::Contain,
|
||||
class: Theme::default(),
|
||||
rotation: Rotation::default(),
|
||||
opacity: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +105,15 @@ where
|
|||
self.rotation = rotation.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the opacity of the [`Svg`].
|
||||
///
|
||||
/// It should be in the [0.0, 1.0] range—`0.0` meaning completely transparent,
|
||||
/// and `1.0` meaning completely opaque.
|
||||
pub fn opacity(mut self, opacity: impl Into<f32>) -> Self {
|
||||
self.opacity = opacity.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
||||
|
|
@ -204,6 +215,7 @@ where
|
|||
style.color,
|
||||
drawing_bounds,
|
||||
self.rotation.radians(),
|
||||
self.opacity,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue