pub struct Color {
pub a: u8,
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
An ARGB color.
Fields§
§a: u8The Alpha component of the color.
r: u8The Red component of the color.
g: u8The Green component of the color.
b: u8The Blue component of the color.
Implementations§
Source§impl Color
impl Color
Sourcepub const fn new(a: u8, r: u8, g: u8, b: u8) -> Self
pub const fn new(a: u8, r: u8, g: u8, b: u8) -> Self
Initializes a new instance of the Color struct.
Sourcepub const fn from_argb(a: u8, r: u8, g: u8, b: u8) -> Color
pub const fn from_argb(a: u8, r: u8, g: u8, b: u8) -> Color
Creates a Color from alpha, red, green and blue components.
Sourcepub const fn from_rgb(r: u8, g: u8, b: u8) -> Color
pub const fn from_rgb(r: u8, g: u8, b: u8) -> Color
Creates an opaque Color from red, green and blue components.
Sourcepub const fn from_uint32(value: u32) -> Color
pub const fn from_uint32(value: u32) -> Color
Creates a Color from an integer in 0xAARRGGBB layout.
Sourcepub fn parse(s: &str) -> Result<Color, FormatError>
pub fn parse(s: &str) -> Result<Color, FormatError>
Parses a color string: #rgb, #argb, #rrggbb, #aarrggbb,
rgb()/rgba(), hsl()/hsla(), hsv()/hsva() or a known color name.
Sourcepub fn try_parse(s: &str) -> Option<Color>
pub fn try_parse(s: &str) -> Option<Color>
Parses a color string, returning None when it is not a valid color.
Sourcepub fn to_string_format(
&self,
format: Option<&str>,
format_provider: Option<&CultureInfo>,
) -> Result<String, FormatError>
pub fn to_string_format( &self, format: Option<&str>, format_provider: Option<&CultureInfo>, ) -> Result<String, FormatError>
Returns the string representation of the color using a format specifier.
Supported format specifiers:
X: XAML hex with alpha,#AARRGGBBx: hex without alpha,#RRGGBBH: HTML/CSS hex with alpha,#RRGGBBAAR/r: CSSrgba(r, g, b, a)/rgb(r, g, b)R%/r%: CSSrgba(r%, g%, b%, a%)/rgb(r%, g%, b%)L,l,L%,l%: converted to HSL and formatted as suchV,v,V%,v%: converted to HSV and formatted as such
A null or empty format is the same as to_string(). Any other format is an
error. format_provider is ignored: color formatting is culture-invariant.
Sourcepub const fn to_uint32(&self) -> u32
pub const fn to_uint32(&self) -> u32
Returns the integer representation of the color in 0xAARRGGBB layout.
Sourcepub fn rgb_to_hsl(red: u8, green: u8, blue: u8, alpha: u8) -> HslColor
pub fn rgb_to_hsl(red: u8, green: u8, blue: u8, alpha: u8) -> HslColor
Converts the given RGBA color component values to their HSL color equivalent.
Sourcepub fn normalized_rgb_to_hsl(r: f64, g: f64, b: f64, a: f64) -> HslColor
pub fn normalized_rgb_to_hsl(r: f64, g: f64, b: f64, a: f64) -> HslColor
Converts the given RGBA color component values to their HSL color equivalent. Warning: no bounds checks or clamping is done on the input component values; they are assumed to be within the 0..1 range. The result is not clamped either.
Sourcepub fn rgb_to_hsv(red: u8, green: u8, blue: u8, alpha: u8) -> HsvColor
pub fn rgb_to_hsv(red: u8, green: u8, blue: u8, alpha: u8) -> HsvColor
Converts the given RGBA color component values to their HSV color equivalent.
Sourcepub fn normalized_rgb_to_hsv(r: f64, g: f64, b: f64, a: f64) -> HsvColor
pub fn normalized_rgb_to_hsv(r: f64, g: f64, b: f64, a: f64) -> HsvColor
Converts the given RGBA color component values to their HSV color equivalent. Warning: no bounds checks or clamping is done on the input component values; they are assumed to be within the 0..1 range. The result is not clamped either.
Trait Implementations§
Source§impl BatchValue for Color
impl BatchValue for Color
impl Copy for Color
Source§impl Display for Color
Writes the known color name when there is one, #aarrggbb (lower-case) otherwise.
impl Display for Color
Writes the known color name when there is one, #aarrggbb (lower-case) otherwise.
impl Eq for Color
Source§impl ExpressionVariantValue for Color
impl ExpressionVariantValue for Color
Source§const FFI_VARIANT_TYPE: Option<VariantType>
const FFI_VARIANT_TYPE: Option<VariantType>
None when the type cannot be a foreign function parameter.Source§fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
Source§fn into_variant(self) -> ExpressionVariant
fn into_variant(self) -> ExpressionVariant
Source§impl From<Color> for ExpressionVariant
impl From<Color> for ExpressionVariant
Source§fn from(value: Color) -> ExpressionVariant
fn from(value: Color) -> ExpressionVariant
Source§impl From<HslColor> for Color
Converts the HSL color to RGB (an explicit conversion in the reference API).
impl From<HslColor> for Color
Converts the HSL color to RGB (an explicit conversion in the reference API).
Source§impl From<HsvColor> for Color
Converts the HSV color to RGB (an explicit conversion in the reference API).
impl From<HsvColor> for Color
Converts the HSV color to RGB (an explicit conversion in the reference API).
Source§impl IInterpolator<Color> for ColorInterpolator
impl IInterpolator<Color> for ColorInterpolator
Source§impl MarkupTyped for Color
impl MarkupTyped for Color
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Source§impl ServerPropertyValue for Color
impl ServerPropertyValue for Color
impl StructuralPartialEq for Color
Source§impl Transition<Color> for ColorTransition
impl Transition<Color> for ColorTransition
Source§fn do_transition(
this: &Self,
progress: Rc<dyn IObservable<f64>>,
old_value: Color,
new_value: Color,
) -> Rc<dyn IObservable<Color>>
fn do_transition( this: &Self, progress: Rc<dyn IObservable<f64>>, old_value: Color, new_value: Color, ) -> Rc<dyn IObservable<Color>>
old_value to new_value, driven by progress (from 0 to 1).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> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more