[][src]Struct embedded_graphics::style::PrimitiveStyleBuilder

pub struct PrimitiveStyleBuilder<C> where
    C: PixelColor
{ /* fields omitted */ }

Primitive style builder.

Use this builder to create PrimitiveStyles. 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 PrimitiveStyles, 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]

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]

impl<C: Copy> Copy for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: Debug> Debug for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: Default> Default for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: Eq> Eq for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: Hash> Hash for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: Ord> Ord for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: PartialEq> PartialEq<PrimitiveStyleBuilder<C>> for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C: PartialOrd> PartialOrd<PrimitiveStyleBuilder<C>> for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C> StructuralEq for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

impl<C> StructuralPartialEq for PrimitiveStyleBuilder<C> where
    C: PixelColor
[src]

Auto Trait Implementations

impl<C> Send for PrimitiveStyleBuilder<C> where
    C: Send

impl<C> Sync for PrimitiveStyleBuilder<C> where
    C: Sync

impl<C> Unpin for PrimitiveStyleBuilder<C> where
    C: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,