Struct embedded_graphics::primitives::rect::Rect
source · pub struct Rect<C: PixelColor> {
pub top_left: Coord,
pub bottom_right: Coord,
pub style: Style<C>,
}
Expand description
Rectangle primitive
Fields
top_left: Coord
Top left point of the rect
bottom_right: Coord
Bottom right point of the rect
style: Style<C>
Object style
Implementations
Trait Implementations
sourceimpl<C: Clone + PixelColor> Clone for Rect<C>
impl<C: Clone + PixelColor> Clone for Rect<C>
sourceimpl<C: Debug + PixelColor> Debug for Rect<C>
impl<C: Debug + PixelColor> Debug for Rect<C>
sourceimpl<C> Dimensions for Rect<C>where
C: PixelColor,
impl<C> Dimensions for Rect<C>where
C: PixelColor,
sourcefn bottom_right(&self) -> Coord
fn bottom_right(&self) -> Coord
Get the bottom right corner of the bounding box for an object
sourcefn size(&self) -> UnsignedCoord
fn size(&self) -> UnsignedCoord
Get the width and height for an object
sourceimpl<'a, C> IntoIterator for &'a Rect<C>where
C: PixelColor,
impl<'a, C> IntoIterator for &'a Rect<C>where
C: PixelColor,
sourceimpl<C> Transform for Rect<C>where
C: PixelColor,
impl<C> Transform for Rect<C>where
C: PixelColor,
sourcefn translate(&self, by: Coord) -> Self
fn translate(&self, by: Coord) -> Self
Translate the rect from its current position to a new position by (x, y) pixels, returning
a new Rect
. For a mutating transform, see translate_mut
.
let rect = Rect::new(Coord::new(5, 10), Coord::new(15, 20))
let moved = rect.translate(Coord::new(10, 10));
assert_eq!(moved.top_left, Coord::new(15, 20));
assert_eq!(moved.bottom_right, Coord::new(25, 30));
sourcefn translate_mut(&mut self, by: Coord) -> &mut Self
fn translate_mut(&mut self, by: Coord) -> &mut Self
Translate the rect from its current position to a new position by (x, y) pixels.
let mut rect = Rect::new(Coord::new(5, 10), Coord::new(15, 20))
rect.translate_mut(Coord::new(10, 10));
assert_eq!(rect.top_left, Coord::new(15, 20));
assert_eq!(rect.bottom_right, Coord::new(25, 30));
sourceimpl<C> WithStyle<C> for Rect<C>where
C: PixelColor,
impl<C> WithStyle<C> for Rect<C>where
C: PixelColor,
sourcefn with_style(self, style: Style<C>) -> Self
fn with_style(self, style: Style<C>) -> Self
Add a complete style to the object
sourcefn with_stroke(self, color: Option<C>) -> Self
fn with_stroke(self, color: Option<C>) -> Self
Set the stroke colour for the object Read more
sourcefn with_stroke_width(self, width: u8) -> Self
fn with_stroke_width(self, width: u8) -> Self
Set the stroke width for the object Read more
impl<C: Copy + PixelColor> Copy for Rect<C>
impl<C> Drawable for Rect<C>where
C: PixelColor,
impl<C> Primitive for Rect<C>where
C: PixelColor,
Auto Trait Implementations
impl<C> RefUnwindSafe for Rect<C>where
C: RefUnwindSafe,
impl<C> Send for Rect<C>where
C: Send,
impl<C> Sync for Rect<C>where
C: Sync,
impl<C> Unpin for Rect<C>where
C: Unpin,
impl<C> UnwindSafe for Rect<C>where
C: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more