pub enum Shape2d {
Point(Vec2),
Line {
start: Vec2,
end: Vec2,
pixel_count: usize,
},
Grid {
start: Vec2,
horizontal_end: Vec2,
vertical_end: Vec2,
horizontal_pixel_count: usize,
vertical_pixel_count: usize,
serpentine: bool,
},
Arc {
center: Vec2,
axis_u: Vec2,
axis_v: Vec2,
start_angle_in_radians: f32,
end_angle_in_radians: f32,
pixel_count: usize,
},
}
Expand description
Enumeration of two-dimensional shape primitives.
Each variant represents a different type of 2D arrangement of LEDs.
Variants§
Point(Vec2)
A single point at the specified location.
Line
A line of LEDs from start
to end
with pixel_count
LEDs.
Fields
Grid
A grid of LEDs defined by three corners and dimensions.
Fields
Arc
A circular or elliptical arc in 2D.
Parametric form:
point(theta) = center + cos(theta) * axis_u + sin(theta) * axis_v
Angle and direction:
- Theta = 0 lies along
axis_u
(i.e.center + axis_u
)- As theta increases, the point moves towards
axis_v
(counter-clockwise in the XY plane).
- As theta increases, the point moves towards
- The arc is traced for theta in
[start_angle_in_radians, end_angle_in_radians]
.- If
end
<start
, the arc goes clockwise.
- If
- Positive angles are counter-clockwise.
- To make a full ellipse, set end = start +
TAU
.
How to choose axis_u
/ axis_v
:
- Axis-aligned circle with with radius
r
:axis_u = (r, 0)
axis_v = (0, r)
- Axis-aligned ellipse with radii
(rx, ry)
:axis_u = (rx, 0)
axis_v = (0, ry)
- Rotated by
phi
:axis_u = ( rx * cos(phi), rx * sin(phi))
axis_v = ( -ry * sin(phi), ry * cos(phi))
Notes:
axis_u
andaxis_v
must not both be zero.axis_u
andaxis_v
need not be unit length of perpendicular.- The points returned by
shape::points()
of aShape2d::Arc
:- Will have uniform density if a circular arc
- Will not have uniform density if an elliptical arc, as the points correspond to
theta
.
Implementations§
Source§impl Shape2d
impl Shape2d
Sourcepub const fn pixel_count(&self) -> usize
pub const fn pixel_count(&self) -> usize
Returns the total number of pixels (LEDs) in this shape.
Sourcepub fn points(&self) -> Shape2dPointsIterator ⓘ
pub fn points(&self) -> Shape2dPointsIterator ⓘ
Returns an iterator over all points (LED positions) in this shape.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shape2d
impl RefUnwindSafe for Shape2d
impl Send for Shape2d
impl Sync for Shape2d
impl Unpin for Shape2d
impl UnwindSafe for Shape2d
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromColor<T> for T
impl<T> FromColor<T> for T
Source§fn from_color(color: T) -> T
fn from_color(color: T) -> T
Converts from the source color type
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Converts into the target color type
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.