()
| 78 | use super::*; |
| 79 | #[test] |
| 80 | fn open_simplex_test() { |
| 81 | let permutation = Permutation::from_seed(make_seed(09512)); |
| 82 | |
| 83 | let mut img = image::RgbaImage::new(512, 512); |
| 84 | let mut min = f32::INFINITY; |
| 85 | let mut max = f32::NEG_INFINITY; |
| 86 | for y in 0..512 { |
| 87 | for x in 0..512 { |
| 88 | // let (xf, yf) = make_uv(x, y); |
| 89 | // let noise = perlin(&perm, xf * 10.0, yf * 10.0); |
| 90 | let noise = open_simplex_2d(&permutation, (x as f32 + 0.0) * 0.01, (y as f32 + 0.0) * 0.01); |
| 91 | if noise < min { |
| 92 | min = noise; |
| 93 | } |
| 94 | if noise > max { |
| 95 | max = noise; |
| 96 | } |
| 97 | let norm = ((noise + 1.0) / 2.0).clamp(0.0, 1.0); |
| 98 | let gray = (norm * 255.0) as u8; |
| 99 | img.put_pixel(x, y, Rgba([gray, gray, gray, 255])); |
| 100 | } |
| 101 | } |
| 102 | println!("Min: {min:.7}\nMax: {max:.7}"); |
| 103 | img.save("noise.png").expect("Failed to save image."); |
| 104 | } |
| 105 | } |
nothing calls this directly
no test coverage detected