[−][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::{ pixelcolor::Rgb565, prelude::*, primitives::Rectangle, style::PrimitiveStyleBuilder, }; // Rectangle with red 3 pixel wide stroke and green fill from (50, 20) to (60, 35) let style = PrimitiveStyleBuilder::new() .stroke_color(Rgb565::RED) .stroke_width(3) .fill_color(Rgb565::GREEN) .build(); Rectangle::new(Point::new(50, 20), Point::new(60, 35)) .into_styled(style) .draw(&mut display)?; // Rectangle with translation applied Rectangle::new(Point::new(50, 20), Point::new(60, 35)) .translate(Point::new(65, 35)) .into_styled(style) .draw(&mut display)?;
Fields
top_left: Point
Top left point of the rect
bottom_right: Point
Bottom right point of the rect
Methods
impl Rectangle
[src]
pub const 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 Clone for Rectangle
[src]
fn clone(&self) -> Rectangle
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Rectangle
[src]
impl Debug for Rectangle
[src]
impl Default for Rectangle
[src]
impl Dimensions for Rectangle
[src]
impl Eq for Rectangle
[src]
impl Hash for Rectangle
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Rectangle
[src]
fn cmp(&self, other: &Rectangle) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Rectangle> for Rectangle
[src]
impl PartialOrd<Rectangle> for Rectangle
[src]
fn partial_cmp(&self, other: &Rectangle) -> Option<Ordering>
[src]
fn lt(&self, other: &Rectangle) -> bool
[src]
fn le(&self, other: &Rectangle) -> bool
[src]
fn gt(&self, other: &Rectangle) -> bool
[src]
fn ge(&self, other: &Rectangle) -> bool
[src]
impl Primitive for Rectangle
[src]
fn into_styled<C>(
self,
style: PrimitiveStyle<C>
) -> Styled<Self, PrimitiveStyle<C>> where
C: PixelColor,
Self: Sized,
[src]
self,
style: PrimitiveStyle<C>
) -> Styled<Self, PrimitiveStyle<C>> where
C: PixelColor,
Self: Sized,
impl StructuralEq for Rectangle
[src]
impl StructuralPartialEq for Rectangle
[src]
impl Transform for Rectangle
[src]
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));
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Scalar for T where
T: PartialEq<T> + Copy + Any + Debug,
[src]
T: PartialEq<T> + Copy + Any + Debug,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
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> 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,