Struct embedded_graphics::primitives::Styled [−][src]
pub struct Styled<T, S> { pub primitive: T, pub style: S, }
Expand description
Styled.
Fields
primitive: T
Primitive.
style: S
Style.
Implementations
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));
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
Returns the bounding box.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<T, S> RefUnwindSafe for Styled<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> UnwindSafe for Styled<T, S> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Performs the conversion.
Performs the conversion.
Casts the value.
type Output = T
type Output = T
Should always be Self
Casts the value.
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) -> bool
Checks 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) -> SS
Use 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) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
Casts the value.
pub fn vzip(self) -> V
Casts the value.