Struct embedded_graphics::primitives::Styled [−][src]
pub struct Styled<T, S> {
pub primitive: T,
pub style: S,
}Expand description
Styled.
Fields
primitive: TPrimitive.
style: SStyle.
Implementations
impl<T: OffsetOutline, C: PixelColor> Styled<T, PrimitiveStyle<C>>[src]
impl<T: OffsetOutline, C: PixelColor> Styled<T, PrimitiveStyle<C>>[src]pub fn fill_area(&self) -> T[src]
pub fn fill_area(&self) -> T[src]Returns the fill area.
The returned primitive coincides with the area that would be filled by calling draw
on this styled primitive.
Examples
use embedded_graphics::{ pixelcolor::Rgb888, prelude::*, primitives::{Circle, PrimitiveStyleBuilder}, }; let style = PrimitiveStyleBuilder::new() .fill_color(Rgb888::RED) .stroke_color(Rgb888::GREEN) .stroke_width(6) .build(); let center = Point::new(10, 20); let diameter = 10; let circle = Circle::with_center(center, diameter).into_styled(style); assert_eq!(circle.fill_area(), Circle::with_center(center, diameter - style.stroke_width));
pub fn stroke_area(&self) -> T[src]
pub fn stroke_area(&self) -> T[src]Returns the stroke area.
The outer edge of the returned primitive coincides with the outer edge of the stroke that
would be drawn by calling draw on this styled primitive.
Examples
This example tests if a point lies on the stroke. Because the stoke area surrounds the stoke and fill an additional test is required to check that the point is not inside the fill area.
use embedded_graphics::{ pixelcolor::Rgb888, prelude::*, primitives::{Circle, PrimitiveStyle}, }; let style = PrimitiveStyle::with_stroke(Rgb888::RED, 6); let center = Point::new(10, 20); let diameter = 10; let circle = Circle::with_center(center, diameter).into_styled(style); // A point lies on the stroke if it is inside the stroke area but not in the fill area. let is_on_stroke = |p| circle.stroke_area().contains(p) && !circle.fill_area().contains(p); assert!(is_on_stroke(center + Size::new(0, diameter / 2))); assert!(!is_on_stroke(center));
Trait Implementations
impl<T: StyledDimensions<S>, S> Dimensions for Styled<T, S>[src]
impl<T: StyledDimensions<S>, S> Dimensions for Styled<T, S>[src]fn bounding_box(&self) -> Rectangle[src]
fn bounding_box(&self) -> Rectangle[src]Returns the bounding box.
impl<T: StyledDrawable<S>, S> Drawable for Styled<T, S>[src]
impl<T: StyledDrawable<S>, S> Drawable for Styled<T, S>[src]impl<T: Ord, S: Ord> Ord for Styled<T, S>[src]
impl<T: Ord, S: Ord> Ord for Styled<T, S>[src]impl<T: PartialOrd, S: PartialOrd> PartialOrd<Styled<T, S>> for Styled<T, S>[src]
impl<T: PartialOrd, S: PartialOrd> PartialOrd<Styled<T, S>> for Styled<T, S>[src]fn partial_cmp(&self, other: &Styled<T, S>) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Styled<T, S>) -> Option<Ordering>[src]This method returns an ordering between self and other values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl<T: Copy, S: Copy> Copy for Styled<T, S>[src]
impl<T: Eq, S: Eq> Eq for Styled<T, S>[src]
impl<T, S> StructuralEq for Styled<T, S>[src]
impl<T, S> StructuralPartialEq for Styled<T, S>[src]
Auto Trait Implementations
impl<T, S> RefUnwindSafe for Styled<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for Styled<T, S> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<T, S> Sync for Styled<T, S> where
S: Sync,
T: Sync,
S: Sync,
T: Sync,
impl<T, S> Unpin for Styled<T, S> where
S: Unpin,
T: Unpin,
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for Styled<T, S> where
S: UnwindSafe,
T: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>, [src]
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>, [src]pub fn lossless_try_into(self) -> Option<Dst>[src]
pub fn lossless_try_into(self) -> Option<Dst>[src]Performs the conversion.
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>, [src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>, [src]pub fn lossy_into(self) -> Dst[src]
pub fn lossy_into(self) -> Dst[src]Performs the conversion.
impl<T> Same<T> for T
impl<T> Same<T> for Ttype Output = T
type Output = TShould always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>, pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>The inverse inclusion map: attempts to construct self from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> boolChecks if self is actually part of its subset T (and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SSUse with care! Same as self.to_subset but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SPThe inclusion map: converts self to the equivalent element of its superset.
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,