#[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) -> Rgba
pub fn blend(&self, other: Rgba) -> Rgba
Create a new Rgba color by blending this and another color together
Sourcepub fn alpha(&self, a: f32) -> Rgba
pub fn alpha(&self, a: f32) -> Rgba
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) -> Rgba
pub fn opacity(&self, factor: f32) -> Rgba
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: D,
) -> Result<Rgba, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Rgba, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl From<Rgba> for Background
impl From<Rgba> for Background
Source§fn from(value: Rgba) -> Background
fn from(value: Rgba) -> Background
Source§impl From<Rgba> for HighlightStyle
impl From<Rgba> for HighlightStyle
Source§fn from(color: Rgba) -> HighlightStyle
fn from(color: Rgba) -> HighlightStyle
Source§impl Interpolate for Rgba
impl Interpolate for Rgba
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 moreSource§impl Serialize for Rgba
impl Serialize for Rgba
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl 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
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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
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().