use std::f64; use sdl2::pixels::Color; fn put_pixel(data: &mut [u8], x: usize, y: usize, color: Color) { data[y * 3 * 800 + x * 3] = color.r; data[y * 3 * 800 + x * 3 + 1] = color.g; data[y * 3 * 800 + x * 3 + 2] = color.b; } pub fn render(data: &mut [u8], frame_count: u32) { let time = frame_count as f64 / 60. * 6.28; let ct = f64::cos(time); let st = f64::sin(time); for x in 0..800 { for y in 0..800 { let cx: f64 = f64::cos(st * 1.0 + (x as f64 - 400.) / 39.123 * ct) + 1.; let cy: f64 = f64::cos(ct * 1.1 + (y as f64 - 400.) / 40.123 * st) + 1.; let sx: f64 = f64::sin(ct * 1.2 + (x as f64 - 400.) / 41.123 * ct) + 1.; let sy: f64 = f64::sin(st * 1.3 + (y as f64 - 400.) / 42.123 * st) + 1.; put_pixel( &mut *data, x, y, Color { r: (cx * 128.) as u8, g: (cy * sx * 64.) as u8, b: (sy * 128.) as u8, a: 0, }, ); } } }