use crate::{Image, Point, Size}; /// A background image. #[derive(Debug, Clone, PartialEq)] pub struct BackgroundImage { // TODO: svg support image: Image, attachment: Attachment, clip: Sizing, origin: Sizing, /// (x, y) repeat: (Repeat, Repeat), size: Size, // filter_method: FilterMethod, // opacity: f32, // TODO: blend mode } impl BackgroundImage { /// Scales the opacity of the [`BackgroundImage`] by the given factor. pub fn scale_opacity(mut self, factor: f32) -> Self { let opacity = self.image.opacity * factor; self.image = self.image.opacity(opacity); self } } /// An attachment property. #[derive(Debug, Clone, Copy, PartialEq, Default)] pub enum Attachment { /// Fixed relative to the viewport. Fixed, /// Fixed relative to self. #[default] Local, } /// A sizing property. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Sizing { /// At outside edge of border. Border, /// At outside edge of padding. Padding, /// At outside edge of content. Content, } /// A repetition property. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Repeat { /// Repeat beginning at offset. Will be clipped if necessary. Repeat(Point), /// Repeated as much as possible without clipping. Whitespace is evenly distributed between each instance. Space, /// Repeated as much as possible without clipping. Stretched until there is room for another to be added. Round, /// No repetition. Position defined by point. Will be clipped if necessary. NoRepeat(Point), }