Skip to main content

SpriteSource

Enum SpriteSource 

Source
pub enum SpriteSource<'a> {
    Bitmap {
        bytes: &'a [u8],
        format: SpriteFormat,
        tint: Color,
    },
    Shader {
        state_hash: u32,
        painter: &'a dyn Fn(&mut dyn SurfacePainter),
    },
    Svg {
        source: StrRef<'a>,
        is_path_only: bool,
        tint: Color,
        stroke_width_x10: u8,
    },
    Arc {
        thickness: u8,
        start_deg10: u16,
        sweep_deg10: u16,
        fill_sweep_deg10: u16,
        track_color: Color,
        fill_color: Color,
    },
}
Expand description

Sprite 贴图数据源(支持静态/帧池预烘焙位图掩码,或过程化 SDF 精灵贴图)。

Variants§

§

Bitmap

预烘焙 A4/A8 Alpha 掩码或 Rgb565 位图切片。

Fields

§bytes: &'a [u8]
§tint: Color
§

Shader

过程化矢量精灵(分配于 ScratchArena,如旋转表针或动态仪表盘层)。

Fields

§state_hash: u32
§painter: &'a dyn Fn(&mut dyn SurfacePainter)
§

Svg

原生矢量 SVG 文档或单路径 d 字符串(纯 POD,支持软件多核条带并行与 GPU SpriteAtlas HiDPI 跨帧缓存)。

Fields

§source: StrRef<'a>

SVG XML 文本或单条 d 路径数据(静态字面量或帧级 ScratchArena 字符串)。

§is_path_only: bool

true 表示 source 为 24×24 标准 SVG Path d 字符串;false 表示完整 <svg> XML 文档。

§tint: Color

前景着色颜色(对应 XML 中的 currentColor 及整体 Alpha 透明度;纯路径模式下作为绘制颜色)。

§stroke_width_x10: u8

0.1px 精度描边宽度(纯路径模式下 0 表示实心填充,>0 如 20 表示 2.0px 圆头描边线条图标;XML 模式下 0 遵循内置 stroke-width)。

§

Arc

原生解析圆弧/圆环 SDF 图元(纯 POD,GPU 端单 Draw Call 片元直算零上传,软件端支持多线程并行光栅)。

Fields

§thickness: u8

圆弧线宽(逻辑像素)。

§start_deg10: u16

起始顺时针角度(单位 0.1°,0 为 12 点钟方向)。

§sweep_deg10: u16

背景轨道总跨度(单位 0.1°)。

§fill_sweep_deg10: u16

前景填充进度跨度(单位 0.1°)。

§track_color: Color

背景轨道颜色。

§fill_color: Color

前景填充颜色。

Trait Implementations§

Source§

impl<'a> Clone for SpriteSource<'a>

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<'a> Copy for SpriteSource<'a>

Source§

impl<'a> Debug for SpriteSource<'a>

Source§

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

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

impl<'a> Eq for SpriteSource<'a>

Source§

impl<'a> PartialEq for SpriteSource<'a>

Source§

fn eq(&self, other: &Self) -> 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<'a> !RefUnwindSafe for SpriteSource<'a>

§

impl<'a> !Send for SpriteSource<'a>

§

impl<'a> !Sync for SpriteSource<'a>

§

impl<'a> !UnwindSafe for SpriteSource<'a>

§

impl<'a> Forget for SpriteSource<'a>

§

impl<'a> Freeze for SpriteSource<'a>

§

impl<'a> Move for SpriteSource<'a>

§

impl<'a> Unpin for SpriteSource<'a>

§

impl<'a> UnsafeUnpin for SpriteSource<'a>

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.