pub struct SolidColor { /* private fields */ }Expand description
A class to represent a solid color.
Instantiate a Color from a 4 unsigned integers in range [0, 255].
Each parameter corresponds to the Color attributes:
rfor redgfor greenbfor blueafor alpha (AKA opacity)
Implementations§
Source§impl SolidColor
impl SolidColor
Sourcepub fn new(r: u8, g: u8, b: u8, a: u8) -> SolidColor
pub fn new(r: u8, g: u8, b: u8, a: u8) -> SolidColor
Instantiate a SolidColor object from the given color components:
rfor redgfor greenbfor blueafor alpha (transparency).0is completely transparent;255is completely opaque.
Sourcepub fn from_string(val: &str) -> Result<SolidColor, ImgGenSpecError>
pub fn from_string(val: &str) -> Result<SolidColor, ImgGenSpecError>
Instantiate a SolidColor from a CSS-style string.
Valid color values include
- named colors (see CSS specifications)
- hexadecimal color codes (
#f00or#ff0000or#ff0000ff) - RGB or RGBA strings (
"rgb(255, 0, 0)"or"rgba(255, 0, 0, 1.0") - HSL or HSLA string (
"hsl(0, 1.0, 1.0)"or"hsla(0, 1.0, 1.0, 1.0)") - HWB or HWBA string (
"hwb(0, 1.0, 1.0)"or"hwba(0, 1.0, 1.0, 1.0)") - HSV or HSVA string (
"hsv(0, 1.0, 1.0)"or"hsva(0, 1.0, 1.0, 1.0)")
Returns an Err if the value is not a CSS color value.
Trait Implementations§
Source§impl Clone for SolidColor
impl Clone for SolidColor
Source§fn clone(&self) -> SolidColor
fn clone(&self) -> SolidColor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SolidColor
impl Debug for SolidColor
Source§impl Default for SolidColor
impl Default for SolidColor
Source§fn default() -> SolidColor
fn default() -> SolidColor
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SolidColor
impl<'de> Deserialize<'de> for SolidColor
Source§fn deserialize<D>(
deserializer: D,
) -> Result<SolidColor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SolidColor, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<SolidColor> for ColorKind
impl From<SolidColor> for ColorKind
Source§fn from(val: SolidColor) -> ColorKind
fn from(val: SolidColor) -> ColorKind
Converts to this type from the input type.
Source§impl Serialize for SolidColor
impl Serialize for SolidColor
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for SolidColor
impl RefUnwindSafe for SolidColor
impl Send for SolidColor
impl Sync for SolidColor
impl Unpin for SolidColor
impl UnsafeUnpin for SolidColor
impl UnwindSafe for SolidColor
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().