pub type Rgba<S = Srgb, T = f32> = Alpha<Rgb<S, T>, T>;
Expand description
Generic RGB with an alpha component. See the Rgba
implementation in
Alpha
.
Aliased Type§
struct Rgba<S = Srgb, T = f32> {
pub color: Rgb<S, T>,
pub alpha: T,
}
Fields§
§color: Rgb<S, T>
The color.
alpha: T
The transparency component. 0.0 (or 0u8) is fully transparent and 1.0 (or 255u8) is fully opaque.
Implementations§
source§impl<S> Rgba<S, u8>
impl<S> Rgba<S, u8>
sourcepub fn into_u32<O>(self) -> u32
pub fn into_u32<O>(self) -> u32
Convert to a packed u32
with with specifiable component order.
use palette::{rgb, Srgba};
let integer = Srgba::new(96u8, 127, 0, 255).into_u32::<rgb::channels::Argb>();
assert_eq!(0xFF607F00, integer);
It’s also possible to use From
and Into
, which defaults to the
0xRRGGBBAA
component order:
use palette::Srgba;
let integer = u32::from(Srgba::new(96u8, 127, 0, 255));
assert_eq!(0x607F00FF, integer);
See Packed for more details.
sourcepub fn from_u32<O>(color: u32) -> Self
pub fn from_u32<O>(color: u32) -> Self
Convert from a packed u32
with specifiable component order.
use palette::{rgb, Srgba};
let rgba = Srgba::from_u32::<rgb::channels::Argb>(0xFF607F00);
assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);
It’s also possible to use From
and Into
, which defaults to the
0xRRGGBBAA
component order:
use palette::Srgba;
let rgba = Srgba::from(0x607F00FF);
assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);
See Packed for more details.