diff options
author | 2024-03-04 20:42:37 +0100 | |
---|---|---|
committer | 2024-03-04 20:42:37 +0100 | |
commit | f4a4845ddbdced81ae4ff60bfa19f0e602d84709 (patch) | |
tree | b532017384eb9e43e57bf73be372aea0d55af652 /core/src/background.rs | |
parent | db92e1c942154bee474fee5e2c187f8a52a1bb96 (diff) | |
download | iced-f4a4845ddbdced81ae4ff60bfa19f0e602d84709.tar.gz iced-f4a4845ddbdced81ae4ff60bfa19f0e602d84709.tar.bz2 iced-f4a4845ddbdced81ae4ff60bfa19f0e602d84709.zip |
Simplify theming for `Button` widget
Diffstat (limited to 'core/src/background.rs')
-rw-r--r-- | core/src/background.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/src/background.rs b/core/src/background.rs index 347c52c0..2e28e560 100644 --- a/core/src/background.rs +++ b/core/src/background.rs @@ -11,6 +11,19 @@ pub enum Background { // TODO: Add image variant } +impl Background { + /// Increases the translucency of the [`Background`] + /// by the given factor. + pub fn transparentize(self, factor: f32) -> Self { + match self { + Self::Color(color) => Self::Color(color.transparentize(factor)), + Self::Gradient(gradient) => { + Self::Gradient(gradient.transparentize(factor)) + } + } + } +} + impl From<Color> for Background { fn from(color: Color) -> Self { Background::Color(color) |