From 27b099c895825ee03555fd7bdaa8cefdb2125ead Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 20 Mar 2025 11:57:26 +0000 Subject: WIP: background image support --- core/src/background.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'core/src/background.rs') 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 for Background { Background::Gradient(Gradient::Linear(gradient)) } } + +impl From for Background { + fn from(background_image: BackgroundImage) -> Self { + Background::Image(background_image) + } +} -- cgit