pub struct Desktop<Dim, Layout> { /* private fields */ }Expand description
Desktop simulator for LED layouts in a desktop window.
Provides a visual representation of your LED layout using miniquad,
with a Driver to render updates.
§Type Parameters
Dim- The dimension marker (Dim1d or Dim2d or Dim3d)Layout- The specific layout type
Implementations§
Source§impl Desktop<Dim1d, ()>
impl Desktop<Dim1d, ()>
Sourcepub fn new_1d<Layout>() -> Desktop<Dim1d, Layout>where
Layout: Layout1d,
pub fn new_1d<Layout>() -> Desktop<Dim1d, Layout>where
Layout: Layout1d,
Creates a new graphics simulator for 1D layouts.
This method initializes a rendering window showing a linear strip of LEDs.
§Type Parameters
Layout- The layout type implementing Layout1d
§Returns
A Desktop simulator configured for the specified 1D layout
Examples found in repository?
15fn main() {
16 Desktop::new_1d::<StripLayout>().start(|driver| {
17 let mut control = ControlBuilder::new_1d()
18 .with_layout::<StripLayout, { StripLayout::PIXEL_COUNT }>()
19 .with_pattern::<Rainbow>(RainbowParams {
20 ..Default::default()
21 })
22 .with_driver(driver)
23 .with_frame_buffer_size::<{ StripLayout::PIXEL_COUNT }>()
24 .build();
25
26 loop {
27 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
28 break;
29 }
30
31 sleep(Duration::from_millis(16));
32 }
33 });
34}Sourcepub fn new_1d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim1d, Layout>where
Layout: Layout1d,
pub fn new_1d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim1d, Layout>where
Layout: Layout1d,
Source§impl Desktop<Dim2d, ()>
impl Desktop<Dim2d, ()>
Sourcepub fn new_2d<Layout>() -> Desktop<Dim2d, Layout>where
Layout: Layout2d,
pub fn new_2d<Layout>() -> Desktop<Dim2d, Layout>where
Layout: Layout2d,
Creates a new graphics simulator for 2D layouts.
This method initializes a rendering window showing a 2D arrangement of LEDs based on the layout’s coordinates.
§Type Parameters
Layout- The layout type implementing Layout2d
§Returns
A Desktop simulator configured for the specified 2D layout
Examples found in repository?
25fn main() {
26 Desktop::new_2d::<PanelLayout>().start(|driver| {
27 let mut control = ControlBuilder::new_2d()
28 .with_layout::<PanelLayout, { PanelLayout::PIXEL_COUNT }>()
29 .with_pattern::<Rainbow>(RainbowParams {
30 ..Default::default()
31 })
32 .with_driver(driver)
33 .with_frame_buffer_size::<{ PanelLayout::PIXEL_COUNT }>()
34 .build();
35
36 loop {
37 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
38 break;
39 }
40
41 sleep(Duration::from_millis(16));
42 }
43 });
44}More examples
25fn main() {
26 Desktop::new_2d::<PanelLayout>().start(|driver| {
27 let mut control = ControlBuilder::new_2d()
28 .with_layout::<PanelLayout, { PanelLayout::PIXEL_COUNT }>()
29 .with_pattern::<Noise2d<noise_fns::Perlin>>(NoiseParams {
30 ..Default::default()
31 })
32 .with_driver(driver)
33 .with_frame_buffer_size::<{ PanelLayout::PIXEL_COUNT }>()
34 .build();
35
36 loop {
37 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
38 break;
39 }
40
41 sleep(Duration::from_millis(16));
42 }
43 });
44}Sourcepub fn new_2d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim2d, Layout>where
Layout: Layout2d,
pub fn new_2d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim2d, Layout>where
Layout: Layout2d,
Source§impl Desktop<Dim3d, ()>
impl Desktop<Dim3d, ()>
Sourcepub fn new_3d<Layout>() -> Desktop<Dim3d, Layout>where
Layout: Layout3d,
pub fn new_3d<Layout>() -> Desktop<Dim3d, Layout>where
Layout: Layout3d,
Creates a new graphics simulator for 3D layouts.
This method initializes a rendering window showing a 3D arrangement of LEDs based on the layout’s coordinates.
§Type Parameters
Layout- The layout type implementing Layout3d
§Returns
A Desktop simulator configured for the specified 3D layout
Examples found in repository?
41fn main() {
42 Desktop::new_3d::<CubeVolumeLayout>().start(|driver| {
43 let mut control = ControlBuilder::new_3d()
44 .with_layout::<CubeVolumeLayout, { CubeVolumeLayout::PIXEL_COUNT }>()
45 .with_pattern::<Rainbow>(RainbowParams::default())
46 .with_driver(driver)
47 .with_frame_buffer_size::<{ CubeVolumeLayout::PIXEL_COUNT }>()
48 .build();
49
50 loop {
51 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
52 break;
53 }
54
55 sleep(Duration::from_millis(16));
56 }
57 });
58}More examples
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}41fn main() {
42 Desktop::new_3d::<CubeVolumeLayout>().start(|driver| {
43 let mut control = ControlBuilder::new_3d()
44 .with_layout::<CubeVolumeLayout, { CubeVolumeLayout::PIXEL_COUNT }>()
45 .with_pattern::<Noise3d<noise_fns::Perlin>>(NoiseParams {
46 time_scalar: 0.25 / 1e3,
47 position_scalar: 0.25,
48 })
49 .with_driver(driver)
50 .with_frame_buffer_size::<{ CubeVolumeLayout::PIXEL_COUNT }>()
51 .build();
52
53 loop {
54 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
55 break;
56 }
57
58 sleep(Duration::from_millis(16));
59 }
60 });
61}13fn main() {
14 layout3d!(
15 CubeFaceLayout,
16 [
17 // bottom face
18 Shape3d::Grid {
19 start: Vec3::new(1., -1., 1.), // right bottom front
20 horizontal_end: Vec3::new(-1., -1., 1.), // left bottom front
21 vertical_end: Vec3::new(1., -1., -1.), // right bottom back
22 horizontal_pixel_count: 16,
23 vertical_pixel_count: 16,
24 serpentine: true,
25 },
26 // back face
27 Shape3d::Grid {
28 start: Vec3::new(-1., -1., -1.), // left bottom back
29 horizontal_end: Vec3::new(-1., 1., -1.), // left top back
30 vertical_end: Vec3::new(1., -1., -1.), // right bottom back
31 horizontal_pixel_count: 16,
32 vertical_pixel_count: 16,
33 serpentine: true,
34 },
35 // right face
36 Shape3d::Grid {
37 start: Vec3::new(1., 1., -1.), // right top back
38 horizontal_end: Vec3::new(1., 1., 1.), // right top front
39 vertical_end: Vec3::new(1., -1., -1.), // right bottom back
40 horizontal_pixel_count: 16,
41 vertical_pixel_count: 16,
42 serpentine: true,
43 },
44 // front face
45 Shape3d::Grid {
46 start: Vec3::new(-1., -1., 1.), // left bottom front
47 horizontal_end: Vec3::new(1., -1., 1.), // right bottom front
48 vertical_end: Vec3::new(-1., 1., 1.), // left top front
49 horizontal_pixel_count: 16,
50 vertical_pixel_count: 16,
51 serpentine: true,
52 },
53 // left face
54 Shape3d::Grid {
55 start: Vec3::new(-1., 1., -1.), // left top back
56 horizontal_end: Vec3::new(-1., -1., -1.), // left bottom back
57 vertical_end: Vec3::new(-1., 1., 1.), // left top front
58 horizontal_pixel_count: 16,
59 vertical_pixel_count: 16,
60 serpentine: true,
61 },
62 // top face
63 Shape3d::Grid {
64 start: Vec3::new(1., 1., 1.), // right top front
65 horizontal_end: Vec3::new(1., 1., -1.), // right top back
66 vertical_end: Vec3::new(-1., 1., 1.), // left top front
67 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}Sourcepub fn new_3d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim3d, Layout>where
Layout: Layout3d,
pub fn new_3d_with_config<Layout>(
config: DesktopConfig,
) -> Desktop<Dim3d, Layout>where
Layout: Layout3d,
Source§impl<Dim, Layout> Desktop<Dim, Layout>
impl<Dim, Layout> Desktop<Dim, Layout>
Sourcepub fn start<F>(self, f: F)
pub fn start<F>(self, f: F)
Examples found in repository?
41fn main() {
42 Desktop::new_3d::<CubeVolumeLayout>().start(|driver| {
43 let mut control = ControlBuilder::new_3d()
44 .with_layout::<CubeVolumeLayout, { CubeVolumeLayout::PIXEL_COUNT }>()
45 .with_pattern::<Rainbow>(RainbowParams::default())
46 .with_driver(driver)
47 .with_frame_buffer_size::<{ CubeVolumeLayout::PIXEL_COUNT }>()
48 .build();
49
50 loop {
51 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
52 break;
53 }
54
55 sleep(Duration::from_millis(16));
56 }
57 });
58}More examples
15fn main() {
16 Desktop::new_1d::<StripLayout>().start(|driver| {
17 let mut control = ControlBuilder::new_1d()
18 .with_layout::<StripLayout, { StripLayout::PIXEL_COUNT }>()
19 .with_pattern::<Rainbow>(RainbowParams {
20 ..Default::default()
21 })
22 .with_driver(driver)
23 .with_frame_buffer_size::<{ StripLayout::PIXEL_COUNT }>()
24 .build();
25
26 loop {
27 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
28 break;
29 }
30
31 sleep(Duration::from_millis(16));
32 }
33 });
34}25fn main() {
26 Desktop::new_2d::<PanelLayout>().start(|driver| {
27 let mut control = ControlBuilder::new_2d()
28 .with_layout::<PanelLayout, { PanelLayout::PIXEL_COUNT }>()
29 .with_pattern::<Rainbow>(RainbowParams {
30 ..Default::default()
31 })
32 .with_driver(driver)
33 .with_frame_buffer_size::<{ PanelLayout::PIXEL_COUNT }>()
34 .build();
35
36 loop {
37 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
38 break;
39 }
40
41 sleep(Duration::from_millis(16));
42 }
43 });
44}25fn main() {
26 Desktop::new_2d::<PanelLayout>().start(|driver| {
27 let mut control = ControlBuilder::new_2d()
28 .with_layout::<PanelLayout, { PanelLayout::PIXEL_COUNT }>()
29 .with_pattern::<Noise2d<noise_fns::Perlin>>(NoiseParams {
30 ..Default::default()
31 })
32 .with_driver(driver)
33 .with_frame_buffer_size::<{ PanelLayout::PIXEL_COUNT }>()
34 .build();
35
36 loop {
37 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
38 break;
39 }
40
41 sleep(Duration::from_millis(16));
42 }
43 });
44}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}41fn main() {
42 Desktop::new_3d::<CubeVolumeLayout>().start(|driver| {
43 let mut control = ControlBuilder::new_3d()
44 .with_layout::<CubeVolumeLayout, { CubeVolumeLayout::PIXEL_COUNT }>()
45 .with_pattern::<Noise3d<noise_fns::Perlin>>(NoiseParams {
46 time_scalar: 0.25 / 1e3,
47 position_scalar: 0.25,
48 })
49 .with_driver(driver)
50 .with_frame_buffer_size::<{ CubeVolumeLayout::PIXEL_COUNT }>()
51 .build();
52
53 loop {
54 if let Err(DesktopError::WindowClosed) = control.tick(elapsed_in_ms()) {
55 break;
56 }
57
58 sleep(Duration::from_millis(16));
59 }
60 });
61}