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
sourceimpl<C> PrimitiveStyle<C> where
C: PixelColor,
impl<C> PrimitiveStyle<C> where
C: PixelColor,
sourcepub fn with_stroke(stroke_color: C, stroke_width: u32) -> Self
pub 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 fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns if a primitive drawn with this style is completely transparent.
Trait Implementations
sourceimpl<C: Clone> Clone for PrimitiveStyle<C> where
C: PixelColor,
impl<C: Clone> Clone for PrimitiveStyle<C> where
C: PixelColor,
sourcefn clone(&self) -> PrimitiveStyle<C>
fn clone(&self) -> PrimitiveStyle<C>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<C: Debug> Debug for PrimitiveStyle<C> where
C: PixelColor,
impl<C: Debug> Debug for PrimitiveStyle<C> where
C: PixelColor,
sourceimpl<C> Default for PrimitiveStyle<C> where
C: PixelColor,
impl<C> Default for PrimitiveStyle<C> where
C: PixelColor,
sourceimpl<C> From<&'_ PrimitiveStyle<C>> for PrimitiveStyleBuilder<C> where
C: PixelColor,
impl<C> From<&'_ PrimitiveStyle<C>> for PrimitiveStyleBuilder<C> where
C: PixelColor,
sourcefn from(style: &PrimitiveStyle<C>) -> Self
fn from(style: &PrimitiveStyle<C>) -> Self
Performs the conversion.
sourceimpl<C: Hash> Hash for PrimitiveStyle<C> where
C: PixelColor,
impl<C: Hash> Hash for PrimitiveStyle<C> where
C: PixelColor,
sourceimpl<C: Ord> Ord for PrimitiveStyle<C> where
C: PixelColor,
impl<C: Ord> Ord for PrimitiveStyle<C> where
C: PixelColor,
sourceimpl<C: PartialEq> PartialEq<PrimitiveStyle<C>> for PrimitiveStyle<C> where
C: PixelColor,
impl<C: PartialEq> PartialEq<PrimitiveStyle<C>> for PrimitiveStyle<C> where
C: PixelColor,
sourcefn eq(&self, other: &PrimitiveStyle<C>) -> bool
fn eq(&self, other: &PrimitiveStyle<C>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PrimitiveStyle<C>) -> bool
fn ne(&self, other: &PrimitiveStyle<C>) -> bool
This method tests for !=
.
sourceimpl<C: PartialOrd> PartialOrd<PrimitiveStyle<C>> for PrimitiveStyle<C> where
C: PixelColor,
impl<C: PartialOrd> PartialOrd<PrimitiveStyle<C>> for PrimitiveStyle<C> where
C: PixelColor,
sourcefn partial_cmp(&self, other: &PrimitiveStyle<C>) -> Option<Ordering>
fn partial_cmp(&self, other: &PrimitiveStyle<C>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Arc
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Arc
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Circle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Circle
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Ellipse
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Ellipse
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Rectangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Rectangle
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for RoundedRectangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for RoundedRectangle
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Sector
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Sector
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Triangle
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Triangle
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Arc
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Arc
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Circle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Circle
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Ellipse
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Ellipse
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Rectangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Rectangle
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for RoundedRectangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for RoundedRectangle
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Sector
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Sector
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Triangle
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Triangle
type Color = C
type Color = C
Color type.
sourcefn 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>,
Draws the primitive using the given style.
impl<C: Copy> Copy for PrimitiveStyle<C> where
C: PixelColor,
impl<C: Eq> Eq for PrimitiveStyle<C> where
C: PixelColor,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcepub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcepub fn checked_cast_from(src: Src) -> Option<Dst>
pub fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcepub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcepub fn overflowing_cast_from(src: Src) -> (Dst, bool)
pub fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcepub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcepub fn saturating_cast_from(src: Src) -> Dst
pub fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcepub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcepub fn unwrapped_cast_from(src: Src) -> Dst
pub fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcepub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcepub fn wrapping_cast_from(src: Src) -> Dst
pub fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.