pub struct RGBA {
pub red: u8,
pub green: u8,
pub blue: u8,
pub alpha: u8,
}Expand description
A color with red, green, blue, and alpha components, in a byte each.
Fields§
§red: u8The red component.
green: u8The green component.
blue: u8The blue component.
alpha: u8The alpha component.
Implementations§
Source§impl RGBA
impl RGBA
Sourcepub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self
Constructs a new RGBA value from float components. It expects the red, green, blue and alpha channels in that order, and all values will be clamped to the 0.0 … 1.0 range.
Sourcepub fn transparent() -> Self
pub fn transparent() -> Self
Returns a transparent color.
Sourcepub fn new(red: u8, green: u8, blue: u8, alpha: f32) -> Self
pub fn new(red: u8, green: u8, blue: u8, alpha: f32) -> Self
Same thing, but with u8 values instead of floats in the 0 to 1 range.
Examples found in repository?
examples/custom_at_rule.rs (line 271)
267 fn visit_token(&mut self, token: &mut TokenOrValue<'i>) -> Result<(), Self::Error> {
268 match token {
269 TokenOrValue::Function(f) if f.name == "theme" => match f.arguments.0.first() {
270 Some(TokenOrValue::Token(Token::String(s))) => match s.as_ref() {
271 "blue-500" => *token = TokenOrValue::Color(CssColor::RGBA(RGBA::new(0, 0, 255, 1.0))),
272 "red-500" => *token = TokenOrValue::Color(CssColor::RGBA(RGBA::new(255, 0, 0, 1.0))),
273 _ => {}
274 },
275 _ => {}
276 },
277 _ => {}
278 }
279
280 token.visit_children(self)
281 }Sourcepub fn red_f32(&self) -> f32
pub fn red_f32(&self) -> f32
Returns the red channel in a floating point number form, from 0 to 1.
Sourcepub fn green_f32(&self) -> f32
pub fn green_f32(&self) -> f32
Returns the green channel in a floating point number form, from 0 to 1.
Trait Implementations§
impl Copy for RGBA
Source§impl From<FloatColor> for RGBA
impl From<FloatColor> for RGBA
Source§fn from(color: FloatColor) -> RGBA
fn from(color: FloatColor) -> RGBA
Converts to this type from the input type.
Source§impl From<PredefinedColor> for RGBA
impl From<PredefinedColor> for RGBA
Source§fn from(color: PredefinedColor) -> RGBA
fn from(color: PredefinedColor) -> RGBA
Converts to this type from the input type.
Source§impl From<RGBA> for SRGBLinear
impl From<RGBA> for SRGBLinear
Source§fn from(t: RGBA) -> SRGBLinear
fn from(t: RGBA) -> SRGBLinear
Converts to this type from the input type.
Source§impl From<SRGBLinear> for RGBA
impl From<SRGBLinear> for RGBA
Source§fn from(t: SRGBLinear) -> RGBA
fn from(t: SRGBLinear) -> RGBA
Converts to this type from the input type.
impl StructuralPartialEq for RGBA
Source§impl<'i, V: ?Sized + Visitor<'i, T>, T: Visit<'i, T, V>> Visit<'i, T, V> for RGBA
Available on crate feature visitor only.
impl<'i, V: ?Sized + Visitor<'i, T>, T: Visit<'i, T, V>> Visit<'i, T, V> for RGBA
Available on crate feature
visitor only.Source§const CHILD_TYPES: VisitTypes
const CHILD_TYPES: VisitTypes
The types of values contained within this value and its children.
This is used to skip branches that don’t have any values requested
by the Visitor.
Auto Trait Implementations§
impl Freeze for RGBA
impl RefUnwindSafe for RGBA
impl Send for RGBA
impl Sync for RGBA
impl Unpin for RGBA
impl UnsafeUnpin for RGBA
impl UnwindSafe for RGBA
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.