[−][src]Struct embedded_graphics::primitives::rectangle::Rectangle
Rectangle primitive
Examples
The macro examples make for more concise code.
Create some rectangles with different styles
use embedded_graphics::prelude::*; use embedded_graphics::primitives::Rectangle; use embedded_graphics::pixelcolor::Rgb565; // Default rect from (10, 20) to (30, 40) let r1 = Rectangle::new(Point::new(10, 20), Point::new(30, 40)); // Rectangle with styled stroke and fill from (50, 20) to (60, 35) let r2 = Rectangle::new(Point::new(50, 20), Point::new(60, 35)) .stroke(Some(Rgb565::RED)) .stroke_width(3) .fill(Some(Rgb565::GREEN)); // Rectangle with translation applied let r3 = Rectangle::new(Point::new(50, 20), Point::new(60, 35)) .translate(Point::new(65, 35)); display.draw(r1); display.draw(r2); display.draw(r3);
Fields
top_left: Point
Top left point of the rect
bottom_right: Point
Bottom right point of the rect
style: Style<C>
Object style
Methods
impl<C> Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
pub fn new(top_left: Point, bottom_right: Point) -> 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 Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> Dimensions for Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> Primitive for Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> WithStyle<C> for Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
fn style(self, style: Style<C>) -> Self
[src]
fn stroke(self, color: Option<C>) -> Self
[src]
fn stroke_width(self, width: u8) -> Self
[src]
fn fill(self, color: Option<C>) -> Self
[src]
impl<C> Transform for Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
fn translate(&self, by: Point) -> Self
[src]
Translate the rect from its current position to a new position by (x, y) pixels, returning
a new Rectangle
. For a mutating transform, see translate_mut
.
let rect = Rectangle::new(Point::new(5, 10), Point::new(15, 20)) let moved = rect.translate(Point::new(10, 10)); assert_eq!(moved.top_left, Point::new(15, 20)); assert_eq!(moved.bottom_right, Point::new(25, 30));
fn translate_mut(&mut self, by: Point) -> &mut Self
[src]
Translate the rect from its current position to a new position by (x, y) pixels.
let mut rect = Rectangle::new(Point::new(5, 10), Point::new(15, 20)) rect.translate_mut(Point::new(10, 10)); assert_eq!(rect.top_left, Point::new(15, 20)); assert_eq!(rect.bottom_right, Point::new(25, 30));
impl<C: Debug + PixelColor> Debug for Rectangle<C>
[src]
impl<C: Copy + PixelColor> Copy for Rectangle<C>
[src]
impl<C> IntoIterator for Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
type Item = Pixel<C>
The type of the elements being iterated over.
type IntoIter = RectangleIterator<C>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, C> IntoIterator for &'a Rectangle<C> where
C: PixelColor,
[src]
C: PixelColor,
type Item = Pixel<C>
The type of the elements being iterated over.
type IntoIter = RectangleIterator<C>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<C: Clone + PixelColor> Clone for Rectangle<C>
[src]
Auto Trait Implementations
impl<C> Unpin for Rectangle<C> where
C: Unpin,
C: Unpin,
impl<C> Send for Rectangle<C> where
C: Send,
C: Send,
impl<C> Sync for Rectangle<C> where
C: Sync,
C: Sync,
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,