Add linear_gradient() helper
This commit is contained in:
parent
491109885d
commit
51e5506cd8
2 changed files with 14 additions and 12 deletions
lights/src
|
@ -60,3 +60,7 @@ pub const fn gray(gray: u8) -> Rgb {
|
|||
pub fn blend(a: Rgb, b: Rgb, mix: Rgb) -> Rgb {
|
||||
(a * Rgb(255 - mix.0, 255 - mix.1, 255 - mix.2)) + (b * mix)
|
||||
}
|
||||
|
||||
pub fn linear_gradient(from: Rgb, to: Rgb, steps: usize) -> impl Iterator<Item = Rgb> + Clone {
|
||||
(0..steps).map(move |x| blend(from, to, gray((x * 255 / steps) as u8)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue