1 use serde
::{Deserialize
, Serialize
};
3 #[derive(Copy, Clone, Debug, Deserialize, Serialize)]
10 // 'value' is between 0 and 1.
11 pub fn linear_interpolation(color1
: RGB
, color2
: RGB
, value
: f32) -> RGB
{
12 let red
= (color1
.red
as f32 + (color2
.red
as f32 - color1
.red
as f32) * value
) as u8;
13 let green
= (color1
.green
as f32 + (color2
.green
as f32 - color1
.green
as f32) * value
) as u8;
14 let blue
= (color1
.blue
as f32 + (color2
.blue
as f32 - color1
.blue
as f32) * value
) as u8;
16 RGB
{ red
, green
, blue
}