#[repr(C)]pub struct Rgba {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
An RGBA color
Fields§
§r: f32The red component of the color, in the range 0.0 to 1.0
g: f32The green component of the color, in the range 0.0 to 1.0
b: f32The blue component of the color, in the range 0.0 to 1.0
a: f32The alpha component of the color, in the range 0.0 to 1.0
Implementations§
Source§impl Rgba
impl Rgba
Sourcepub fn blend(&self, other: Rgba) -> Self
pub fn blend(&self, other: Rgba) -> Self
Create a new Rgba color by blending this and another color together
Sourcepub fn alpha(&self, a: f32) -> Self
pub fn alpha(&self, a: f32) -> Self
Returns a new RGBA color with the same red, green and blue channels, but with a new alpha value.
Example:
use gpui::rgba;
let color = rgba(0xFF0000FF);
let faded = color.alpha(0.25);
assert_eq!(faded.a, 0.25);This will return a red color with 25% opacity.
Example:
use gpui::rgba;
let color = rgba(0x3399FFCC);
let transparent = color.alpha(0.0);
assert_eq!(transparent.a, 0.0);This will return the same blue color, fully transparent.
Sourcepub fn opacity(&self, factor: f32) -> Self
pub fn opacity(&self, factor: f32) -> Self
Returns a new RGBA color with the same red, green, and blue channels, but with the alpha channel multiplied by the given factor.
Example:
use gpui::rgba;
let color = rgba(0xFF0000FF); // Fully opaque red
let faded = color.opacity(0.5);
assert_eq!(faded.a, 0.5);This will return a red color with 50% opacity.
Example:
use gpui::rgba;
let color = rgba(0x3399FFCC); // A light blue with 80% opacity
let faded = color.opacity(0.5);
assert!((faded.a - 0.4).abs() < 1e-6);This will return the same blue color scaled down to 40% opacity.
Trait Implementations§
impl Copy for Rgba
Source§impl<'de> Deserialize<'de> for Rgba
impl<'de> Deserialize<'de> for Rgba
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl From<Rgba> for Background
impl From<Rgba> for Background
Source§impl From<Rgba> for HighlightStyle
impl From<Rgba> for HighlightStyle
Source§impl JsonSchema for Rgba
impl JsonSchema for Rgba
Source§fn json_schema(_generator: &mut SchemaGenerator) -> Schema
fn json_schema(_generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Rgba
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> 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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().