ombre 0.6.7

Shadowy game and graphics library for Rust
Documentation
//! Color blending.

/// A pixel-wise comparison function.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub enum Comparison {
    #[default]
    Always,
    Never,
    Less,
    LessOrEqual,
    Greater,
    GreaterOrEqual,
    Equal,
    NotEqual,
}

/// Specifies how incoming RGBA values (source) and RGBA values
/// in a framebuffer (destination) are combined.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub enum BlendOp {
    /// Adds source to destination. Source and destination are multiplied
    /// by the blending parameters before addition.
    #[default]
    Add,
    /// Subtracts destination from source. Source and destination are
    /// multiplied by the blending parameters before subtraction.
    Subtract,
    /// Subtracts source from destination. Source and destination are
    /// multiplied by the blending parameters before subtraction.
    SubtractReverse,
}

/// Blend values.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BlendValue {
    SourceColor,
    SourceAlpha,
    DestinationColor,
    DestinationAlpha,
}

/// Blend factors.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BlendFactor {
    Zero,
    One,
    Value(BlendValue),
    OneMinusValue(BlendValue),
    SourceAlphaSaturate,
}

/// A blending equation.
///
/// Can be described as `op(sfactor * source, dfactor * destination)`
/// The default is pre-multiplied alpha blending, ie. `destination.rgb = source.rgb * source.a +
/// destination.rgb * (1 - source.a)`
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct BlendEquation {
    /// Blend operation.
    pub op: BlendOp,
    /// Source factor.
    pub sfactor: BlendFactor,
    /// Destination factor.
    pub dfactor: BlendFactor,
}

impl Default for BlendEquation {
    fn default() -> Self {
        BlendEquation {
            op: BlendOp::Add,
            sfactor: BlendFactor::Value(BlendValue::SourceAlpha),
            dfactor: BlendFactor::OneMinusValue(BlendValue::SourceAlpha),
        }
    }
}