#[repr(transparent)]pub struct Color(pub u32);Expand description
ARGB8888 32 位颜色表示(0xAARRGGBB)。
Tuple Fields§
§0: u32Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
完全透明色。
Sourcepub const fn hex_alpha(rgba: u32) -> Self
pub const fn hex_alpha(rgba: u32) -> Self
从 32 位十六进制 0xRRGGBBAA 整数构造颜色(如 Color::hex_alpha(0x171717cc))。
Sourcepub const fn lerp(self, other: Self, t_256: u16) -> Self
pub const fn lerp(self, other: Self, t_256: u16) -> Self
定点数颜色线性插值(t_256 取值范围 0..=256)。
正确处理透明色与半透明色(预乘 Alpha 权重插值):
当任一端为完全透明(a == 0,如 Color::TRANSPARENT)时保留另一端的 RGB 色相、仅插值 Alpha,
彻底消除 Outline / Ghost 等透明底按钮在亮色/暗色主题下悬停过渡时的黑灰闪烁。
Sourcepub const fn scale_alpha(self, opacity: u8) -> Self
pub const fn scale_alpha(self, opacity: u8) -> Self
按给定不透明度 opacity(0..=255)调制当前颜色的 Alpha 通道。
Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Forget for Color
impl Freeze for Color
impl Move for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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) 时执行闭包修饰自身,否则原样返回。