use super::{EffectQuality, Rect};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum BlendMode {
#[default]
Over,
Add,
Multiply,
Screen,
Darken,
Lighten,
Subtract,
}
impl BlendMode {
pub const COUNT: usize = 7;
pub const ALL: [BlendMode; Self::COUNT] = [
BlendMode::Over,
BlendMode::Add,
BlendMode::Multiply,
BlendMode::Screen,
BlendMode::Darken,
BlendMode::Lighten,
BlendMode::Subtract,
];
pub const fn pipeline_index(self) -> usize {
match self {
BlendMode::Over => 0,
BlendMode::Add => 1,
BlendMode::Multiply => 2,
BlendMode::Screen => 3,
BlendMode::Darken => 4,
BlendMode::Lighten => 5,
BlendMode::Subtract => 6,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CompositeGroupDesc {
pub bounds: Rect,
pub mode: BlendMode,
pub quality: EffectQuality,
pub opacity: f32,
}
impl CompositeGroupDesc {
pub const fn new(bounds: Rect, mode: BlendMode, quality: EffectQuality) -> Self {
Self {
bounds,
mode,
quality,
opacity: 1.0,
}
}
pub fn with_opacity(mut self, opacity: f32) -> Self {
self.opacity = opacity;
self
}
}