pub struct Color(pub f32, pub f32, pub f32, pub f32);Tuple Fields§
§0: f32§1: f32§2: f32§3: f32Implementations§
Source§impl Color
impl Color
pub const BLACK: Color
pub const WHITE: Color
pub const RED: Color
pub const GREEN: Color
pub const BLUE: Color
pub const TRANSPARENT: Color
pub const fn rgb(r: f32, g: f32, b: f32) -> Color
pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
pub const fn from_rgb_u8(r: u8, g: u8, b: u8) -> Color
pub fn r(&self) -> f32
pub fn g(&self) -> f32
pub fn b(&self) -> f32
pub fn a(&self) -> f32
pub fn with_alpha(&self, alpha: f32) -> Color
Trait Implementations§
impl Copy for Color
Source§impl Lerp for Color
impl Lerp for Color
Source§fn lerp(&self, target: &Color, fraction: f32) -> Color
fn lerp(&self, target: &Color, fraction: f32) -> Color
Linearly interpolate each RGBA channel, including alpha.
Jetpack Compose’s default Color lerp converts through the Oklab
color space before interpolating. Cranpose colors carry no color-space
information, so this implementation interpolates each channel linearly
in the color’s own (linear RGBA) space instead. For typical UI fades
between colors in the same space this closely matches Compose’s
behavior; the results are clamped to [0.0, 1.0] per channel so
overshooting springs still produce valid colors, matching Compose’s
gamut coercion.
Source§impl RenderHash for Color
impl RenderHash for Color
fn render_hash(&self) -> u64
Source§impl SpringScalar for Color
impl SpringScalar for Color
Source§fn to_f32(&self) -> f32
fn to_f32(&self) -> f32
Magnitude of the RGBA vector.
Only a coarse scalar view: spring progress and settling for colors use
the 4-channel overrides below, mirroring how Compose animates colors
as AnimationVector4D.
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze 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