/** Gobble up a `ColorSpec` and calculate the vector of colors. */
Gobble up a `ColorSpec` and calculate the vector of colors.
Gobble up a ` ColorSpec ` and calculate the vector of colors .
pub fn make(spec: ColorSpec) -> ColorMap {
        let mut colors: Vec<RGB> = Vec::with_capacity(spec.length);
        let default = spec.default;
        for grad in spec.gradients.iter() {
            let dr = grad.end.r - grad.start.r;
            let dg = grad.end.g - grad.start.g;
            let db = grad.end.b - grad.start.b;
            let steps_f = grad.steps as f32;
            for n in 0..grad.steps {
                let frac = (n as f32) / steps_f;
                let c = RGB::new(
                    grad.start.r + frac * dr,
                    grad.start.g + frac * dg,
                    grad.start.b + frac * db,
                );
                colors.push(c);
            }
        }
        ColorMap { colors, default }
    }
pub fn make ( spec : ColorSpec ) -> ColorMap { let mut colors : Vec < RGB > = Vec :: with_capacity ( spec . length ) ; let default = spec . default ; for grad in spec . gradients . iter ( ) { let dr = grad . end . r - grad . start . r ; let dg = grad . end . g - grad . start . g ; let db = grad . end . b - grad . start . b ; let steps_f = grad . steps as f32 ; for n in 0 .. grad . steps { let frac = ( n as f32 ) / steps_f ; let c = RGB :: new ( grad . start . r + frac * dr , grad . start . g + frac * dg , grad . start . b + frac * db , ) ; colors . push ( c ) ; } } ColorMap { colors , default } }
Gobble up a `ColorSpec` and calculate the vector of colors.
Gobble up a ` ColorSpec ` and calculate the vector of colors .
spec
ColorSpec