Struct embedded_iconoir::Icon

source ·
pub struct Icon<C, Ico>
where C: PixelColor, Ico: IconoirInternal,
{ /* private fields */ }
Expand description

Struct to store icon color and properties.

There are two ways to instantiate an icon:

// using constructors on icons (recommended)
let icon = icons::size24px::actions::Download::new(BinaryColor::On);
// using types
let icon: Icon<_, icons::size24px::actions::Download> = Icon::new(BinaryColor::On);

Both result in the same icon (Icon<COLOR, ICON>). Use whichever you prefer.

Full Usage Example

// Import icons and traits
use embedded_iconoir::prelude::*;

// Create an icon
let icon = icons::size24px::actions::Download::new(BinaryColor::On);

// Wrap it in an embedded_graphics image
let image = Image::new(&icon, Point::zero());

// Draw it to a display
image.draw(&mut display).unwrap();

Implementations§

source§

impl<C: PixelColor, Ico: IconoirInternal> Icon<C, Ico>

source

pub fn new(color: C) -> Self

source

pub fn set_color(&mut self, color: C)

source

pub fn get_color(&self) -> C

Trait Implementations§

source§

impl<C, Ico> Debug for Icon<C, Ico>
where C: PixelColor + Debug, Ico: IconoirInternal + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C, T> ImageDrawable for Icon<C, T>
where T: IconoirInternal, C: PixelColor,

§

type Color = C

The color type.
source§

fn draw<D>(&self, target: &mut D) -> Result<(), D::Error>
where D: DrawTarget<Color = Self::Color>,

Draws the entire image to the target. Read more
source§

fn draw_sub_image<D>( &self, target: &mut D, area: &Rectangle ) -> Result<(), D::Error>
where D: DrawTarget<Color = Self::Color>,

Draws a part of the image to the target. Read more
source§

impl<C, T> OriginDimensions for Icon<C, T>
where T: IconoirInternal, C: PixelColor,

source§

fn size(&self) -> Size

Returns the size of the bounding box.

Auto Trait Implementations§

§

impl<C, Ico> RefUnwindSafe for Icon<C, Ico>

§

impl<C, Ico> Send for Icon<C, Ico>
where C: Send, Ico: Send,

§

impl<C, Ico> Sync for Icon<C, Ico>
where C: Sync, Ico: Sync,

§

impl<C, Ico> Unpin for Icon<C, Ico>
where C: Unpin, Ico: Unpin,

§

impl<C, Ico> UnwindSafe for Icon<C, Ico>
where C: UnwindSafe, Ico: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> Dimensions for T
where T: OriginDimensions,

§

fn bounding_box(&self) -> Rectangle

Returns the bounding box.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> ImageDrawableExt for T
where T: ImageDrawable,

source§

fn sub_image(&self, area: &Rectangle) -> SubImage<'_, T>

Returns a sub image of this image drawable. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.