rustfmt modals tests

This commit is contained in:
nworbnhoj 2022-06-14 16:19:02 +10:00
parent dda78b4ef3
commit 5be713d09e

View file

@ -177,24 +177,26 @@ pub fn spawn_test() {
// https://sequelaencollection.home.blog/2d-chaotic-attractors/
fn clifford() -> Img {
const SIZE: u32 = Modals::MODAL_WIDTH;
const CENTER:f32 = (SIZE/2) as f32;
const SCALE:f32 = 70.0;
const CENTER: f32 = (SIZE / 2) as f32;
const SCALE: f32 = 70.0;
let mut buf = vec![255u8; (SIZE * SIZE).try_into().unwrap()];
let (a, b, c, d) = (-2.0, -2.4,1.1, -0.9);
let (mut x,mut y):(f32, f32) = (0.0, 0.0);
for _ in 0..=10000000 {
let x1 = f32::sin(a*y) + c * f32::cos(a*x);
let y1 = f32::sin(b*x) + d*f32::cos(b*y);
let (a, b, c, d) = (-2.0, -2.4, 1.1, -0.9);
let (mut x, mut y): (f32, f32) = (0.0, 0.0);
for _ in 0..=4000000 {
let x1 = f32::sin(a * y) + c * f32::cos(a * x);
let y1 = f32::sin(b * x) + d * f32::cos(b * y);
(x, y) = (x1, y1);
let (a,b):(u32, u32) = ((x * SCALE + CENTER) as u32, (y * SCALE + CENTER) as u32);
let i:usize = (a + SIZE * b).try_into().unwrap();
if buf[i] >0 { buf[i] -= 1; }
let (a, b): (u32, u32) = ((x * SCALE + CENTER) as u32, (y * SCALE + CENTER) as u32);
let i: usize = (a + SIZE * b).try_into().unwrap();
if buf[i] > 0 {
buf[i] -= 1;
}
}
let mut rgb = vec![0u8; 3 * buf.len()];
let mut i:usize = 0;
let mut i: usize = 0;
while i < buf.len() {
let j = 3 * i;
(rgb[j], rgb[j+1], rgb[j+2]) = (buf[i],buf[i],buf[i]);
(rgb[j], rgb[j + 1], rgb[j + 2]) = (buf[i], buf[i], buf[i]);
i += 1;
}
Img::new(rgb, SIZE.try_into().unwrap())