2019-10-16 11:39:41 +00:00
|
|
|
use noise::{Seedable, SuperSimplex};
|
|
|
|
|
2019-06-25 15:59:09 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
const W: usize = 640;
|
|
|
|
const H: usize = 640;
|
|
|
|
|
|
|
|
fn main() {
|
2019-06-26 00:27:41 +00:00
|
|
|
let mut win = minifb::Window::new("Turb", W, H, minifb::WindowOptions::default()).unwrap();
|
2019-06-25 15:59:09 +00:00
|
|
|
|
2019-10-16 11:39:41 +00:00
|
|
|
let _nz_x = SuperSimplex::new().set_seed(0);
|
|
|
|
let _nz_y = SuperSimplex::new().set_seed(1);
|
2019-06-25 15:59:09 +00:00
|
|
|
|
2019-12-09 09:50:14 +00:00
|
|
|
let mut _time = 0.0f64;
|
|
|
|
|
2019-06-25 15:59:09 +00:00
|
|
|
while win.is_open() {
|
|
|
|
let mut buf = vec![0; W * H];
|
|
|
|
|
|
|
|
for i in 0..W {
|
|
|
|
for j in 0..H {
|
|
|
|
let pos = Vec2::new(i as f64 / W as f64, j as f64 / H as f64) * 0.5 - 0.25;
|
|
|
|
|
|
|
|
let pos = pos * 10.0;
|
|
|
|
|
2019-06-26 00:27:41 +00:00
|
|
|
let pos = (0..10).fold(pos, |pos, _| pos.map(|e| e.powf(3.0) - 1.0));
|
2019-06-25 15:59:09 +00:00
|
|
|
|
2019-06-26 00:27:41 +00:00
|
|
|
let val = if pos.map(|e| e.abs() < 0.5).reduce_and() {
|
2019-06-25 15:59:09 +00:00
|
|
|
1.0f32
|
|
|
|
} else {
|
|
|
|
0.0
|
|
|
|
};
|
|
|
|
|
|
|
|
buf[j * W + i] = u32::from_le_bytes([(val.max(0.0).min(1.0) * 255.0) as u8; 4]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
win.update_with_buffer(&buf).unwrap();
|
|
|
|
|
2019-12-09 09:50:14 +00:00
|
|
|
_time += 1.0 / 60.0;
|
2019-06-25 15:59:09 +00:00
|
|
|
}
|
|
|
|
}
|