pub enum Paint<'a> {
Solid(Color),
LinearGradient {
start: [f32; 2],
end: [f32; 2],
stops: &'a [ColorStop],
extend: ExtendMode,
space: GradientSpace,
},
RadialGradient {
center: [f32; 2],
radius: f32,
focal: [f32; 2],
focal_radius: f32,
stops: &'a [ColorStop],
extend: ExtendMode,
space: GradientSpace,
},
ConicGradient {
center: [f32; 2],
start_angle_deg: f32,
sweep_deg: f32,
stops: &'a [ColorStop],
extend: ExtendMode,
space: GradientSpace,
},
}Expand description
通用填充画刷原语(零堆分配,渐变色标借用自 ScratchArena 或 'static 切片)。
Variants§
Solid(Color)
纯色填充。
LinearGradient
任意角度/任意起止点多色标线性渐变(start/end 为归一化局部坐标 [0.0..=1.0])。
RadialGradient
支持双圆焦点偏移的多色标径向渐变(所有坐标与半径均为归一化局部坐标,相对元素宽高的最小边或各自轴)。
ConicGradient
多色标锥形/扫描渐变(start_angle_deg 以 12 点钟为 0° 顺时针增加,sweep_deg 默认 360°)。
Implementations§
Source§impl<'a> Paint<'a>
impl<'a> Paint<'a>
Sourcepub fn linear_angle(angle_deg: f32, stops: &'a [ColorStop]) -> Self
pub fn linear_angle(angle_deg: f32, stops: &'a [ColorStop]) -> Self
按 CSS 角度规范构造多色标线性渐变(0° 向上、90° 向右、180° 向下,135° 左上至右下)。
Sourcepub const fn radial_focal(
center: [f32; 2],
radius: f32,
focal: [f32; 2],
focal_radius: f32,
stops: &'a [ColorStop],
) -> Self
pub const fn radial_focal( center: [f32; 2], radius: f32, focal: [f32; 2], focal_radius: f32, stops: &'a [ColorStop], ) -> Self
构造带焦点的双圆径向渐变。
Sourcepub const fn conic(start_angle_deg: f32, stops: &'a [ColorStop]) -> Self
pub const fn conic(start_angle_deg: f32, stops: &'a [ColorStop]) -> Self
构造居中锥形/扫描渐变(start_angle_deg 以 12 点钟为 0° 顺时针)。
Sourcepub const fn with_extend(self, mode: ExtendMode) -> Self
pub const fn with_extend(self, mode: ExtendMode) -> Self
设置渐变的延展模式(Pad / Repeat / Reflect)。
Sourcepub const fn with_space(self, color_space: GradientSpace) -> Self
pub const fn with_space(self, color_space: GradientSpace) -> Self
设置渐变的色彩插值空间(Srgb / LinearRgb / Oklab)。
Sourcepub fn is_fully_transparent(&self) -> bool
pub fn is_fully_transparent(&self) -> bool
判断该画刷是否全范围完全透明(可安全跳过填充绘制)。
Sourcepub fn is_fully_opaque(&self) -> bool
pub fn is_fully_opaque(&self) -> bool
判断该画刷是否在所有采样点都 100% 不透明。
Trait Implementations§
impl<'a> Copy for Paint<'a>
impl<'a> Eq for Paint<'a>
Auto Trait Implementations§
impl<'a> Forget for Paint<'a>
impl<'a> Freeze for Paint<'a>
impl<'a> Move for Paint<'a>
impl<'a> RefUnwindSafe for Paint<'a>
impl<'a> Send for Paint<'a>
impl<'a> Sync for Paint<'a>
impl<'a> Unpin for Paint<'a>
impl<'a> UnsafeUnpin for Paint<'a>
impl<'a> UnwindSafe for Paint<'a>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
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
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
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。