1use blinksy::{
2 layout::{Layout3d, Shape3d, Vec3},
3 layout3d,
4 patterns::noise::{noise_fns, Noise3d, NoiseParams},
5 ControlBuilder,
6};
7use blinksy_desktop::{
8 driver::{Desktop, DesktopError},
9 time::elapsed_in_ms,
10};
11use std::{thread::sleep, time::Duration};
12
13fn main() {
14 layout3d!(
15 CubeFaceLayout,
16 [
17 Shape3d::Grid {
19 start: Vec3::new(1., -1., 1.), horizontal_end: Vec3::new(-1., -1., 1.), vertical_end: Vec3::new(1., -1., -1.), horizontal_pixel_count: 16,
23 vertical_pixel_count: 16,
24 serpentine: true,
25 },
26 Shape3d::Grid {
28 start: Vec3::new(-1., -1., -1.), horizontal_end: Vec3::new(-1., 1., -1.), vertical_end: Vec3::new(1., -1., -1.), horizontal_pixel_count: 16,
32 vertical_pixel_count: 16,
33 serpentine: true,
34 },
35 Shape3d::Grid {
37 start: Vec3::new(1., 1., -1.), horizontal_end: Vec3::new(1., 1., 1.), vertical_end: Vec3::new(1., -1., -1.), horizontal_pixel_count: 16,
41 vertical_pixel_count: 16,
42 serpentine: true,
43 },
44 Shape3d::Grid {
46 start: Vec3::new(-1., -1., 1.), horizontal_end: Vec3::new(1., -1., 1.), vertical_end: Vec3::new(-1., 1., 1.), horizontal_pixel_count: 16,
50 vertical_pixel_count: 16,
51 serpentine: true,
52 },
53 Shape3d::Grid {
55 start: Vec3::new(-1., 1., -1.), horizontal_end: Vec3::new(-1., -1., -1.), vertical_end: Vec3::new(-1., 1., 1.), horizontal_pixel_count: 16,
59 vertical_pixel_count: 16,
60 serpentine: true,
61 },
62 Shape3d::Grid {
64 start: Vec3::new(1., 1., 1.), horizontal_end: Vec3::new(1., 1., -1.), vertical_end: Vec3::new(-1., 1., 1.), horizontal_pixel_count: 16,
68 vertical_pixel_count: 16,
69 serpentine: true,
70 }
71 ]
72 );
73
74 Desktop::new_3d::<CubeFaceLayout>().start(|driver| {
75 let mut control = ControlBuilder::new_3d()
76 .with_layout::<CubeFaceLayout, { CubeFaceLayout::PIXEL_COUNT }>()
77 .with_pattern::<Noise3d<noise_fns::Perlin>>(NoiseParams {
78 ..Default::default()
79 })
80 .with_driver(driver)
81 .with_frame_buffer_size::<{ CubeFaceLayout::PIXEL_COUNT }>()
82 .build();
83
84 loop {
85 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
86 break;
87 }
88
89 sleep(Duration::from_millis(16));
90 }
91 });
92}