Desktop

Struct Desktop 

Source
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, ()>

Source

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?
examples/1d-rainbow.rs (line 16)
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}
Source

pub fn new_1d_with_config<Layout>( config: DesktopConfig, ) -> Desktop<Dim1d, Layout>
where Layout: Layout1d,

Creates a new graphics simulator for 1D layouts with custom configuration.

§Type Parameters
  • Layout - The layout type implementing Layout1d
§Parameters
  • config - Configuration options for the simulator window
§Returns

A Desktop simulator configured for the specified 1D layout

Source§

impl Desktop<Dim2d, ()>

Source

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?
examples/2d-rainbow.rs (line 26)
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
Hide additional examples
examples/2d-noise.rs (line 26)
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}
Source

pub fn new_2d_with_config<Layout>( config: DesktopConfig, ) -> Desktop<Dim2d, Layout>
where Layout: Layout2d,

Creates a new graphics simulator for 2D layouts with custom configuration.

§Type Parameters
  • Layout - The layout type implementing Layout2d
§Parameters
  • config - Configuration options for the simulator window
§Returns

A Desktop simulator configured for the specified 2D layout

Source§

impl Desktop<Dim3d, ()>

Source

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?
examples/3d-cube-volume-rainbow.rs (line 42)
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
Hide additional examples
examples/3d-arcs.rs (line 64)
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}
examples/3d-cube-volume-noise.rs (line 42)
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}
examples/3d-cube-face-noise.rs (line 74)
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}
Source

pub fn new_3d_with_config<Layout>( config: DesktopConfig, ) -> Desktop<Dim3d, Layout>
where Layout: Layout3d,

Creates a new graphics simulator for 3D layouts with custom configuration.

§Type Parameters
  • Layout - The layout type implementing Layout3d
§Parameters
  • config - Configuration options for the simulator window
§Returns

A Desktop simulator configured for the specified 3D layout

Source§

impl<Dim, Layout> Desktop<Dim, Layout>
where Dim: 'static + Send, Layout: 'static + Send,

Source

pub fn start<F>(self, f: F)
where F: 'static + FnOnce(DesktopDriver<Dim, Layout>) + Send,

Examples found in repository?
examples/3d-cube-volume-rainbow.rs (lines 42-57)
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
Hide additional examples
examples/1d-rainbow.rs (lines 16-33)
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}
examples/2d-rainbow.rs (lines 26-43)
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}
examples/2d-noise.rs (lines 26-43)
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}
examples/3d-arcs.rs (lines 64-80)
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}
examples/3d-cube-volume-noise.rs (lines 42-60)
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}

Auto Trait Implementations§

§

impl<Dim, Layout> Freeze for Desktop<Dim, Layout>

§

impl<Dim, Layout> RefUnwindSafe for Desktop<Dim, Layout>
where Dim: RefUnwindSafe, Layout: RefUnwindSafe,

§

impl<Dim, Layout> Send for Desktop<Dim, Layout>
where Dim: Send, Layout: Send,

§

impl<Dim, Layout> !Sync for Desktop<Dim, Layout>

§

impl<Dim, Layout> Unpin for Desktop<Dim, Layout>
where Dim: Unpin, Layout: Unpin,

§

impl<Dim, Layout> UnwindSafe for Desktop<Dim, Layout>
where Dim: UnwindSafe, Layout: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromColor<T> for T

Source§

fn from_color(color: T) -> T

Converts from the source color type
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Converts into the target color type
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.