summaryrefslogtreecommitdiffstats
path: root/core/src/background.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-04 20:42:37 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-04 20:42:37 +0100
commitf4a4845ddbdced81ae4ff60bfa19f0e602d84709 (patch)
treeb532017384eb9e43e57bf73be372aea0d55af652 /core/src/background.rs
parentdb92e1c942154bee474fee5e2c187f8a52a1bb96 (diff)
downloadiced-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.rs13
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)