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 core::f32::consts::PI;
12use std::{thread::sleep, time::Duration};
13
14layout3d!(
15 TunnelLayout,
17 [
18 Shape3d::Arc {
20 center: Vec3::new(0., -1., -1.),
21 axis_u: Vec3::new(1., 0., 0.),
22 axis_v: Vec3::new(0., 1., 0.), start_angle_in_radians: 0.0,
24 end_angle_in_radians: PI,
25 pixel_count: 60,
26 },
27 Shape3d::Arc {
28 center: Vec3::new(0., -1., -0.5),
29 axis_u: Vec3::new(1., 0., 0.),
30 axis_v: Vec3::new(0., 1.25, 0.), start_angle_in_radians: 0.0,
32 end_angle_in_radians: PI,
33 pixel_count: 68,
34 },
35 Shape3d::Arc {
36 center: Vec3::new(0., -1., 0.),
37 axis_u: Vec3::new(1., 0., 0.),
38 axis_v: Vec3::new(0., 1.5, 0.), start_angle_in_radians: 0.0,
40 end_angle_in_radians: PI,
41 pixel_count: 76,
42 },
43 Shape3d::Arc {
44 center: Vec3::new(0., -1., 0.5),
45 axis_u: Vec3::new(1., 0., 0.),
46 axis_v: Vec3::new(0., 1.75, 0.), start_angle_in_radians: 0.0,
48 end_angle_in_radians: PI,
49 pixel_count: 84,
50 },
51 Shape3d::Arc {
53 center: Vec3::new(0., -1., 1.),
54 axis_u: Vec3::new(1., 0., 0.),
55 axis_v: Vec3::new(0., 2., 0.), start_angle_in_radians: 0.0,
57 end_angle_in_radians: PI,
58 pixel_count: 93,
59 },
60 ]
61);
62
63fn main() {
64 Desktop::new_3d::<TunnelLayout>().start(|driver| {
65 let mut control = ControlBuilder::new_3d()
66 .with_layout::<TunnelLayout, { TunnelLayout::PIXEL_COUNT }>()
67 .with_pattern::<Noise3d<noise_fns::Perlin>>(NoiseParams {
68 ..Default::default()
69 })
70 .with_driver(driver)
71 .with_frame_buffer_size::<{ TunnelLayout::PIXEL_COUNT }>()
72 .build();
73
74 loop {
75 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
76 break;
77 }
78 sleep(Duration::from_millis(16));
79 }
80 });
81}