pub struct Color { /* private fields */ }
Expand description
A platform-independent color type.
§System Colors
Each platform has its own defaults, which can be applied using the
SystemColor
enumeration. To create a Color
, simply call
Into::into
or Color::system()
.
let label_color = Color::system(SystemColor::Label);
§Usage
These colors can be set on Views
using their respective
methods. For example:
let label = Label::new("Hello, Red World!")
.with_color(Color::system(SystemColor::Red));
§RGB
You can also create raw RGB and RGBA colors using:
let blue = Color::rgb(0x00, 0x00, 0xFF);
let translucent_red = Color::rgba(255, 0, 0, 127);
Implementations§
Source§impl Color
impl Color
Sourcepub const fn system(color: SystemColor) -> Self
pub const fn system(color: SystemColor) -> Self
Create a new color, based on platform-dependent
SystemColors
.
Sourcepub const fn rgb(red: u8, green: u8, blue: u8) -> Self
pub const fn rgb(red: u8, green: u8, blue: u8) -> Self
Create a new color from 8-bit RGB colors.
Sourcepub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self
pub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self
Create a new color from 8-bit RGBA colors.
Sourcepub const fn transparent() -> Self
pub const fn transparent() -> Self
Create a fully transparent color.
Trait Implementations§
Source§impl From<SystemColor> for Color
impl From<SystemColor> for Color
Source§fn from(value: SystemColor) -> Self
fn from(value: SystemColor) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin 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