Skip to main content

VectorIcon

Struct VectorIcon 

Source
pub struct VectorIcon(/* private fields */);
Expand description

An icon the app draws, as path data in the SVG path syntax (M0 0L10 10Z, arcs too), which SVG files, XAML’s and Avalonia’s geometries and most icon sets use. A leading F0 (even-odd) or F1 (non-zero), as XAML’s path data has, sets the fill rule; non-zero by default.

It’s filled in the colour the platform gives symbolic icons: AppKit draws it as a template image, GTK as a symbolic SVG, Kirigami as a mask, WinUI as a PathIcon.

Implementations§

Source§

impl VectorIcon

Source

pub fn new(data: &str) -> Result<VectorIcon, String>

The path fitted to its own bounds, as XAML’s Path with uniform stretch shows it.

Source

pub fn with_view_box(data: &str, view_box: Rect) -> Result<VectorIcon, String>

The path in a view box, as an SVG file’s viewBox: icon sets draw on a grid (24 by 24, say), with room around each shape.

Source

pub fn view_box(&self) -> Rect

Source

pub fn even_odd(&self) -> bool

Whether it fills by the even-odd rule, not the non-zero one.

Source

pub fn steps(&self, side: f32) -> Vec<PathStep>

The path in a square of side points, its view box fitted inside, keeping its proportions, and centred; y goes down.

Source

pub fn path_data(&self, side: f32) -> String

The path data fitted in a square of side points, as for steps: for platforms that take path data (XAML).

Source

pub fn svg(&self, side: f32) -> String

An SVG file of it, side points square, filled black: for platforms that recolour symbolic SVGs (GTK, Kirigami).

Trait Implementations§

Source§

impl Clone for VectorIcon

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VectorIcon

Its size, not its path: props print in snapshots.

Source§

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

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

impl IntoValue<VectorIcon> for VectorIcon

Source§

impl PartialEq for VectorIcon

Source§

fn eq(&self, other: &VectorIcon) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for VectorIcon

§

impl Freeze for VectorIcon
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for VectorIcon

§

impl RefUnwindSafe for VectorIcon

§

impl Send for VectorIcon
where Arc<Inner>: Send,

§

impl Sync for VectorIcon
where Arc<Inner>: Sync,

§

impl Unpin for VectorIcon
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for VectorIcon
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

§

impl UnwindSafe for VectorIcon
where Arc<Inner>: 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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.