summaryrefslogtreecommitdiffstats
path: root/core/src/background.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-20 11:57:26 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-20 11:57:26 +0000
commit27b099c895825ee03555fd7bdaa8cefdb2125ead (patch)
tree4b77fc19db7785884c4a67e85e452bb140e13688 /core/src/background.rs
parentbae25b74f68078e5ff74cdae717273cf315d4e90 (diff)
downloadiced-master.tar.gz
iced-master.tar.bz2
iced-master.zip
WIP: background image supportmaster
Diffstat (limited to '')
-rw-r--r--core/src/background.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/src/background.rs b/core/src/background.rs
index 1f665ef4..98430020 100644
--- a/core/src/background.rs
+++ b/core/src/background.rs
@@ -1,14 +1,22 @@
-use crate::Color;
+mod background_image;
+
+use std::sync::Arc;
+
+use background_image::BackgroundImage;
+
use crate::gradient::{self, Gradient};
+use crate::image::{FilterMethod, Handle};
+use crate::{Color, Image, Point, Rectangle, Size, image};
/// The background of some element.
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Background {
/// A solid color.
Color(Color),
/// Linearly interpolate between several colors.
Gradient(Gradient),
- // TODO: Add image variant
+ /// A background image.
+ Image(BackgroundImage),
}
impl Background {
@@ -20,6 +28,9 @@ impl Background {
Self::Gradient(gradient) => {
Self::Gradient(gradient.scale_alpha(factor))
}
+ Self::Image(background_image) => {
+ Self::Image(background_image.scale_opacity(factor))
+ }
}
}
}
@@ -41,3 +52,9 @@ impl From<gradient::Linear> for Background {
Background::Gradient(Gradient::Linear(gradient))
}
}
+
+impl From<BackgroundImage> for Background {
+ fn from(background_image: BackgroundImage) -> Self {
+ Background::Image(background_image)
+ }
+}