pub struct LwRectangle<T, U> {
pub top_left: LwPoint<T>,
pub size: LwSize<U>,
}Expand description
Lightweight rectangle type with configurable coordinate and dimension types.
This struct represents a 2D rectangle with a top-left point and size,
using configurable integer types for coordinates and dimensions. It’s designed
to be more memory-efficient than standard embedded_graphics::Rectangle
for embedded systems.
§Type Parameters
T- The coordinate type for the top-left point (typically i8 or i16)U- The dimension type for the size (typically u8 or u16)
§Example
use matrix_gui::prelude::*;
// Create a rectangle
let rect = LwRectangle::new(
LwPoint::new(10, 20),
LwSize::new(100, 200)
);
// Convert from embedded_graphics Rectangle
let eg_rect = embedded_graphics::primitives::Rectangle::new(
embedded_graphics::geometry::Point::new(10, 20),
embedded_graphics::geometry::Size::new(100, 200)
);
let lw_rect: LwRectangle<i16, u16> = eg_rect.into();Fields§
§top_left: LwPoint<T>The top-left corner of the rectangle.
size: LwSize<U>The size of the rectangle.
Implementations§
Source§impl<T, U> LwRectangle<T, U>
impl<T, U> LwRectangle<T, U>
Source§impl LwRectangle<i16, u16>
impl LwRectangle<i16, u16>
Sourcepub fn center_scale(
&self,
horizontal_percent: u16,
vertical_percent: u16,
) -> Self
pub fn center_scale( &self, horizontal_percent: u16, vertical_percent: u16, ) -> Self
Scales the rectangle around its center by the given percentage.
§Arguments
percent- The percentage to scale by (100% means no change). 200% means double the size, 50% means half the size, etc.
Sourcepub fn delta_resize(&self, delta: DeltaResize) -> Self
pub fn delta_resize(&self, delta: DeltaResize) -> Self
Resizes the rectangle using the specified resize delta.
Sourcepub fn rectangle(&self) -> Rectangle
pub fn rectangle(&self) -> Rectangle
Converts the LwRectangle to an embedded_graphics::Rectangle.
Sourcepub fn resized(
&self,
width: u16,
height: u16,
anchor_point: AnchorPoint,
) -> Self
pub fn resized( &self, width: u16, height: u16, anchor_point: AnchorPoint, ) -> Self
Resizes the rectangle to the specified width and height, using the given anchor point.
Trait Implementations§
Source§impl<T: Clone, U: Clone> Clone for LwRectangle<T, U>
impl<T: Clone, U: Clone> Clone for LwRectangle<T, U>
Source§fn clone(&self) -> LwRectangle<T, U>
fn clone(&self) -> LwRectangle<T, U>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Default, U: Default> Default for LwRectangle<T, U>
impl<T: Default, U: Default> Default for LwRectangle<T, U>
Source§fn default() -> LwRectangle<T, U>
fn default() -> LwRectangle<T, U>
Source§impl From<LwRectangle<i16, u16>> for Rectangle
Converts LwRectangle<i16, u16> to embedded_graphics::Rectangle.
impl From<LwRectangle<i16, u16>> for Rectangle
Converts LwRectangle<i16, u16> to embedded_graphics::Rectangle.
Source§impl From<LwRectangle<i8, u8>> for Rectangle
Converts LwRectangle<i8, u8> to embedded_graphics::Rectangle.
impl From<LwRectangle<i8, u8>> for Rectangle
Converts LwRectangle<i8, u8> to embedded_graphics::Rectangle.
Source§impl From<Rectangle> for LwRectangle<i16, u16>
Converts an embedded_graphics::Rectangle to LwRectangle<i16, u16> using saturating cast.
impl From<Rectangle> for LwRectangle<i16, u16>
Converts an embedded_graphics::Rectangle to LwRectangle<i16, u16> using saturating cast.
Source§impl From<Rectangle> for LwRectangle<i8, u8>
Converts an embedded_graphics::Rectangle to LwRectangle<i8, u8> using saturating cast.
impl From<Rectangle> for LwRectangle<i8, u8>
Converts an embedded_graphics::Rectangle to LwRectangle<i8, u8> using saturating cast.