[−][src]Struct embedded_graphics::style::PrimitiveStyleBuilder
Primitive style builder.
Use this builder to create PrimitiveStyle
s. If any properties on the builder are omitted,
the value will remain at its default value.
The primitive_style!
macro can also be used to create PrimitiveStyle
s, but with a
shorter syntax. See the primitive_style!
documentation for examples.
Examples
Build a style with configured stroke and fill
This example builds a style for a circle with a 3px red stroke and a solid green fill. The circle is centered at (20, 20) with a radius of 10px.
use embedded_graphics::{ egtext, pixelcolor::Rgb565, prelude::*, primitives::Circle, style::{PrimitiveStyle, PrimitiveStyleBuilder}, }; let style: PrimitiveStyle<Rgb565> = PrimitiveStyleBuilder::new() .stroke_color(Rgb565::RED) .stroke_width(3) .fill_color(Rgb565::GREEN) .build(); let circle = Circle::new(Point::new(20, 20), 10).into_styled(style);
Build a style with stroke and no fill
This example builds a style for a rectangle with a 1px red stroke. Because .fill_color()
is
not called, the fill color remains the default value of None
(i.e. transparent).
use embedded_graphics::{ egtext, pixelcolor::Rgb565, prelude::*, primitives::Rectangle, style::{PrimitiveStyle, PrimitiveStyleBuilder}, }; let style: PrimitiveStyle<Rgb565> = PrimitiveStyleBuilder::new() .stroke_color(Rgb565::RED) .stroke_width(1) .build(); let rectangle = Rectangle::new(Point::new(20, 20), Point::new(40, 30)).into_styled(style);
Methods
impl<C> PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
pub fn new() -> Self
[src]
Creates a new primitive style builder.
pub fn fill_color(self, fill_color: C) -> Self
[src]
Sets the fill color.
pub fn stroke_color(self, stroke_color: C) -> Self
[src]
Sets the stroke color.
pub fn stroke_width(self, stroke_width: u32) -> Self
[src]
Sets the stroke width.
pub fn build(self) -> PrimitiveStyle<C>
[src]
Builds the primitive style.
Trait Implementations
impl<C: Clone> Clone for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
fn clone(&self) -> PrimitiveStyleBuilder<C>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<C: Copy> Copy for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C: Debug> Debug for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C: Default> Default for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
fn default() -> PrimitiveStyleBuilder<C>
[src]
impl<C: Eq> Eq for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C: Hash> Hash for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
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<C: Ord> Ord for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
fn cmp(&self, other: &PrimitiveStyleBuilder<C>) -> 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<C: PartialEq> PartialEq<PrimitiveStyleBuilder<C>> for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
fn eq(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
fn ne(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
impl<C: PartialOrd> PartialOrd<PrimitiveStyleBuilder<C>> for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
fn partial_cmp(&self, other: &PrimitiveStyleBuilder<C>) -> Option<Ordering>
[src]
fn lt(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
fn le(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
fn gt(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
fn ge(&self, other: &PrimitiveStyleBuilder<C>) -> bool
[src]
impl<C> StructuralEq for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> StructuralPartialEq for PrimitiveStyleBuilder<C> where
C: PixelColor,
[src]
C: PixelColor,
Auto Trait Implementations
impl<C> Send for PrimitiveStyleBuilder<C> where
C: Send,
C: Send,
impl<C> Sync for PrimitiveStyleBuilder<C> where
C: Sync,
C: Sync,
impl<C> Unpin for PrimitiveStyleBuilder<C> where
C: Unpin,
C: Unpin,
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>,