[][src]Struct embedded_graphics::primitives::rect::Rect

pub struct Rect<C: PixelColor> {
    pub top_left: Coord,
    pub bottom_right: Coord,
    pub style: Style<C>,
}

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

Methods

impl<C> Rect<C> where
    C: PixelColor
[src]

pub fn new(top_left: Coord, bottom_right: Coord) -> Self[src]

Create a new rectangle from the top left point to the bottom right point with a given style

Trait Implementations

impl<C> Drawable for Rect<C> where
    C: PixelColor
[src]

impl<C> Dimensions for Rect<C> where
    C: PixelColor
[src]

impl<C> Primitive for Rect<C> where
    C: PixelColor
[src]

impl<C> WithStyle<C> for Rect<C> where
    C: PixelColor
[src]

impl<C> Transform for Rect<C> where
    C: PixelColor
[src]

fn translate(&self, by: Coord) -> Self[src]

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));

fn translate_mut(&mut self, by: Coord) -> &mut Self[src]

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));

impl<C: Debug + PixelColor> Debug for Rect<C>[src]

impl<C: Copy + PixelColor> Copy for Rect<C>[src]

impl<'a, C> IntoIterator for &'a Rect<C> where
    C: PixelColor
[src]

type Item = Pixel<C>

The type of the elements being iterated over.

type IntoIter = RectIterator<C>

Which kind of iterator are we turning this into?

impl<C: Clone + PixelColor> Clone for Rect<C>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<C> Send for Rect<C> where
    C: Send

impl<C> Sync for Rect<C> where
    C: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]