pub struct Icon {
pub name: &'static str,
pub svg_bytes: &'static [u8],
}Expand description
A compile-time embedded SVG icon.
Icons are embedded at compile time using include_bytes!, which means
they are part of the binary and don’t require filesystem access at runtime.
Create your own with icon_from_path!.
§Example
use egui::Vec2;
use egui_charts::icons::icons;
ui.add(icons::SETTINGS.as_image(Vec2::splat(20.0)));Fields§
§name: &'static strName/path of the icon (for debugging and cache keys)
svg_bytes: &'static [u8]Raw SVG bytes embedded at compile time
Implementations§
Source§impl Icon
impl Icon
Sourcepub const fn new(name: &'static str, svg_bytes: &'static [u8]) -> Self
pub const fn new(name: &'static str, svg_bytes: &'static [u8]) -> Self
Create a new icon from embedded bytes.
This is typically called via the icon_from_path! macro.
Sourcepub fn as_image(&self, size: Vec2) -> Image<'static>
pub fn as_image(&self, size: Vec2) -> Image<'static>
Convert to an egui Image widget with the specified size.
§Arguments
size- The size to render the icon at (width and height)
Sourcepub fn as_image_tinted(&self, size: Vec2, tint: Color32) -> Image<'static>
pub fn as_image_tinted(&self, size: Vec2, tint: Color32) -> Image<'static>
Convert to an egui Image widget with the specified size and tint color.
§Arguments
size- The size to render the icon attint- The color to tint the icon with
Sourcepub fn as_image_square(&self, size: f32) -> Image<'static>
pub fn as_image_square(&self, size: f32) -> Image<'static>
Convert to an egui Image widget with square dimensions.
§Arguments
size- The size (both width and height) to render the icon at
Sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
Get the name/path of this icon (useful for debugging).
Convert to an egui Button widget with the icon.
The button will automatically tint the icon to match text color, providing proper visual feedback for hover/active states.
§Arguments
size- The size to render the icon at
Convert to an egui Button widget with the icon and a text label.
§Arguments
size- The size to render the icon atlabel- The text label to display next to the icon
Convert to an egui Button widget with square icon dimensions.
§Arguments
size- The size (both width and height) to render the icon at
Trait Implementations§
impl Copy for Icon
impl Eq for Icon
Auto Trait Implementations§
impl Freeze for Icon
impl RefUnwindSafe for Icon
impl Send for Icon
impl Sync for Icon
impl Unpin for Icon
impl UnsafeUnpin for Icon
impl UnwindSafe for Icon
Blanket Implementations§
impl<T> AsId for T
impl<T> AsIdSalt for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more