Struct embedded_graphics::primitives::PrimitiveStyle
source · #[non_exhaustive]pub struct PrimitiveStyle<C>where
C: PixelColor,{
pub fill_color: Option<C>,
pub stroke_color: Option<C>,
pub stroke_width: u32,
pub stroke_alignment: StrokeAlignment,
}
Expand description
Style properties for primitives.
PrimitiveStyle
can be applied to a primitive to define how the primitive
is drawn.
Because PrimitiveStyle
has the non_exhaustive
attribute, it cannot be created using a
struct literal. To create a PrimitiveStyle
, the with_stroke
and
with_fill
methods can be used for styles that only require a stroke or
fill respectively. For more complex styles, use the PrimitiveStyleBuilder
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.fill_color: Option<C>
Fill color of the primitive.
If fill_color
is set to None
no fill will be drawn.
stroke_color: Option<C>
Stroke color of the primitive.
If stroke_color
is set to None
or the stroke_width
is set to 0
no stroke will be
drawn.
stroke_width: u32
Stroke width in pixels.
stroke_alignment: StrokeAlignment
Stroke alignment.
The stroke alignment sets if the stroke is drawn inside, outside or centered on the outline of a shape.
This property only applies to closed shapes (rectangle, circle, …) and is ignored for open shapes (line, …).
Implementations§
source§impl<C> PrimitiveStyle<C>where
C: PixelColor,
impl<C> PrimitiveStyle<C>where C: PixelColor,
sourcepub const fn with_stroke(stroke_color: C, stroke_width: u32) -> Self
pub const fn with_stroke(stroke_color: C, stroke_width: u32) -> Self
Creates a stroke primitive style.
If the stroke_width
is 0
the resulting style won’t draw a stroke.
sourcepub const fn is_transparent(&self) -> bool
pub const fn is_transparent(&self) -> bool
Returns if a primitive drawn with this style is completely transparent.
Trait Implementations§
source§impl<C> Clone for PrimitiveStyle<C>where
C: PixelColor + Clone,
impl<C> Clone for PrimitiveStyle<C>where C: PixelColor + Clone,
source§fn clone(&self) -> PrimitiveStyle<C>
fn clone(&self) -> PrimitiveStyle<C>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<C> Debug for PrimitiveStyle<C>where
C: PixelColor + Debug,
impl<C> Debug for PrimitiveStyle<C>where C: PixelColor + Debug,
source§impl<C> Default for PrimitiveStyle<C>where
C: PixelColor,
impl<C> Default for PrimitiveStyle<C>where C: PixelColor,
source§impl<C> Format for PrimitiveStyle<C>where
C: PixelColor + Format,
impl<C> Format for PrimitiveStyle<C>where C: PixelColor + Format,
source§impl<C> From<&PrimitiveStyle<C>> for PrimitiveStyleBuilder<C>where
C: PixelColor,
impl<C> From<&PrimitiveStyle<C>> for PrimitiveStyleBuilder<C>where C: PixelColor,
source§fn from(style: &PrimitiveStyle<C>) -> Self
fn from(style: &PrimitiveStyle<C>) -> Self
source§impl<C> Hash for PrimitiveStyle<C>where
C: PixelColor + Hash,
impl<C> Hash for PrimitiveStyle<C>where C: PixelColor + Hash,
source§impl<C> Ord for PrimitiveStyle<C>where
C: PixelColor + Ord,
impl<C> Ord for PrimitiveStyle<C>where C: PixelColor + Ord,
source§fn cmp(&self, other: &PrimitiveStyle<C>) -> Ordering
fn cmp(&self, other: &PrimitiveStyle<C>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<C> PartialEq<PrimitiveStyle<C>> for PrimitiveStyle<C>where
C: PixelColor + PartialEq,
impl<C> PartialEq<PrimitiveStyle<C>> for PrimitiveStyle<C>where C: PixelColor + PartialEq,
source§fn eq(&self, other: &PrimitiveStyle<C>) -> bool
fn eq(&self, other: &PrimitiveStyle<C>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<C> PartialOrd<PrimitiveStyle<C>> for PrimitiveStyle<C>where
C: PixelColor + PartialOrd,
impl<C> PartialOrd<PrimitiveStyle<C>> for PrimitiveStyle<C>where C: PixelColor + PartialOrd,
source§fn partial_cmp(&self, other: &PrimitiveStyle<C>) -> Option<Ordering>
fn partial_cmp(&self, other: &PrimitiveStyle<C>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Arc
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Arc
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Circle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Circle
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Ellipse
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Ellipse
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Rectangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Rectangle
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for RoundedRectangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for RoundedRectangle
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Sector
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Sector
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Triangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Triangle
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Arc
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Arc
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Circle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Circle
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Ellipse
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Ellipse
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Rectangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Rectangle
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for RoundedRectangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for RoundedRectangle
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Sector
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Sector
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Triangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Triangle
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
impl<C> Copy for PrimitiveStyle<C>where C: PixelColor + Copy,
impl<C> Eq for PrimitiveStyle<C>where C: PixelColor + Eq,
impl<C> StructuralEq for PrimitiveStyle<C>where C: PixelColor,
impl<C> StructuralPartialEq for PrimitiveStyle<C>where C: PixelColor,
Auto Trait Implementations§
impl<C> RefUnwindSafe for PrimitiveStyle<C>where C: RefUnwindSafe,
impl<C> Send for PrimitiveStyle<C>where C: Send,
impl<C> Sync for PrimitiveStyle<C>where C: Sync,
impl<C> Unpin for PrimitiveStyle<C>where C: Unpin,
impl<C> UnwindSafe for PrimitiveStyle<C>where C: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.