RKTK API Docs RKTK Home Repo

Trait Layout2d

Source
pub trait Layout2d {
    const PIXEL_COUNT: usize;

    // Required method
    fn shapes() -> impl Iterator<Item = Shape2d>;

    // Provided method
    fn points() -> impl Iterator<Item = Vec2> { ... }
}
Expand description

Trait for two-dimensional LED layouts.

Implementors of this trait represent a 2D arrangement of LEDs using one or more shapes.

Use layout2d! to define a type that implements Layout2d.

For our 2D space, we can think of:

  • (-1.0, -1.0) as the bottom left
  • (1.0, -1.0) as the bottom right
  • (-1.0, 1.0) as the top left
  • (1.0, 1.0) as the top right

Required Associated Constants§

Source

const PIXEL_COUNT: usize

The total number of LEDs in this layout.

Required Methods§

Source

fn shapes() -> impl Iterator<Item = Shape2d>

Returns an iterator over the shapes that make up this layout.

Provided Methods§

Source

fn points() -> impl Iterator<Item = Vec2>

Returns an iterator over all points (LED positions) in this layout.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§