rocketsplash-rt 0.2.2

Runtime library for loading and rendering Rocketsplash assets (.rst, .rsf)
Documentation
// <FILE>crates/rocketsplash-rt/src/color/fnc_gradient.rs</FILE>
// <DESC>Linear RGB gradient interpolation helper</DESC>
// <VERS>VERSION: 1.0.0</VERS>
// <WCTX>Runtime library implementation</WCTX>
// <CLOG>Add gradient interpolation function</CLOG>

use rocketsplash_formats::Rgb;

pub fn gradient_color(start: Rgb, end: Rgb, t: f32) -> Rgb {
    let t = t.clamp(0.0, 1.0);
    let r = start.r as f32 + (end.r as f32 - start.r as f32) * t;
    let g = start.g as f32 + (end.g as f32 - start.g as f32) * t;
    let b = start.b as f32 + (end.b as f32 - start.b as f32) * t;
    Rgb {
        r: r.round() as u8,
        g: g.round() as u8,
        b: b.round() as u8,
    }
}

// <FILE>crates/rocketsplash-rt/src/color/fnc_gradient.rs</FILE>
// <VERS>END OF VERSION: 1.0.0</VERS>