kahlo 0.0.3

Optimized software rendering library.
Documentation
/// inserts colour blending implementation into the current context.
///
/// expects as input: 2x `Rf32x8`
macro_rules! rgba_simple_blend {
    ($backdrop:ident, $source:ident) => {{
        let c255 = Rf32x8::from_constant(255.0f32);

        let bvec = $backdrop / c255;
        let svec = $source / c255;

        let c1 = Rf32x8::from_constant(1.0f32);
        let salpha = svec.extract_alpha_rgba();
        let balpha = bvec.extract_alpha_rgba();

        let rgb = (bvec * balpha).fma(c1 - salpha, svec * salpha);
        let rgba = rgb.copy_alpha_from(salpha.fma(c1 - balpha, balpha));

        (rgba * c255)
    }};
}
pub(crate) use rgba_simple_blend;

/// inserts colour blending implementation into the current context.
///
/// expects as input: 2x `Ri16x16`
macro_rules! rgba_source_blend {
    ($backdrop:ident, $source:ident) => {{
        let salpha = $source.extract_alpha_rgba();
        let nsvec = $source.copy_alpha_rgba(Ri16x16::from_constant(255));
        nsvec.mix($backdrop, salpha)
    }};
}
pub(crate) use rgba_source_blend;

/// inserts colour blending implementation into the current context.
///
/// expects as input: 2x `Ri16x16`
macro_rules! rgba_backdrop_blend {
    ($backdrop:ident, $source:ident) => {{
        let ealpha = $backdrop.extract_alpha_rgba();
        let nbvec = $backdrop.copy_alpha_rgba($source);
        let nsvec = $source.copy_alpha_rgba(Ri16x16::from_constant(255));
        nsvec.mix(nbvec, ealpha)
    }};
}

pub(crate) use rgba_backdrop_blend;

/// inserts colour blending implementation into the current context.
///
/// expects as input: 2x `Ri16x16`
macro_rules! rgba_multiply_blend {
    ($backdrop:ident, $source:ident) => {{
        ($backdrop * $source).div_255()
    }};
}

pub(crate) use rgba_multiply_blend;