From 6fe5fdcc1a17c6a85e2d3bac34513b057ba3fa9e Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Fri, 29 Nov 2024 18:58:27 +0100 Subject: [PATCH] animations: clean up casts for future 16 bit coord support --- src/animations.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/animations.rs b/src/animations.rs index c4cd768..22ec683 100644 --- a/src/animations.rs +++ b/src/animations.rs @@ -20,7 +20,7 @@ struct SolidShader {} impl Shader for SolidShader { fn draw(&self, _coords: &VirtualCoordinates, frame: usize) -> RGB8 { - Hsv::new_srgb((frame / 4 % 255) as u8, 255, sin8((frame % 64) as u8)).into_rgb8() + Hsv::new_srgb((frame % 255) as u8, 255, sin8((frame % 64) as u8)).into_rgb8() } } @@ -29,7 +29,7 @@ struct ShimmerShader {} impl Shader for ShimmerShader { fn draw(&self, coords: &VirtualCoordinates, frame: usize) -> RGB8 { - Hsv::new_srgb(coords.x.wrapping_add((frame / 3) as u8), coords.y, sin8(frame as u8 % 255).max(75).min(64)).into_rgb8() + Hsv::new_srgb(((coords.x as usize).wrapping_add(frame / 3) % 255) as u8, coords.y, sin8(frame).max(75).min(64)).into_rgb8() } } @@ -40,14 +40,14 @@ impl Shader for ThinkingShader { fn draw(&self, coords: &VirtualCoordinates, frame: usize) -> RGB8 { //let noise_x = sin8(sin8((frame % 255) as u8).wrapping_add(coords.x)); //let noise_y = cos8(cos8((frame % 255) as u8).wrapping_add(coords.y)); - let offset_x = sin8(((frame % 255) as u8).wrapping_add(coords.x)); - let offset_y = cos8(((frame % 255) as u8).wrapping_add(coords.y)); + let offset_x = sin8(frame.wrapping_add(coords.x as usize)); + let offset_y = cos8(frame.wrapping_add(coords.y as usize)); let noise_x = offset_x / 2; let noise_y = offset_y / 2; //let noise_x = coords.x.wrapping_add(offset_x); //let noise_y = coords.y.wrapping_add(offset_y); Hsv::new_srgb( - inoise8(noise_x as i16, noise_y as i16), + inoise8(offset_x as i16, offset_y as i16), 128_u8.saturating_add(inoise8(noise_y as i16, noise_x as i16)), 255 ).into_rgb8()