pub struct Color(pub [u8; 4]);Expand description
An RGBA colour with 8 bits per channel (alpha 255 is opaque).
Parsed from the strings ImageMagick accepts for borders and backgrounds:
#rgb, #rgba, #rrggbb, #rrggbbaa, rgb(r, g, b), rgba(r, g, b, a)
(channels as 0–255 or percentages, alpha as 0–1), the CSS colour names,
transparent and none. The empty string is ImageMagick’s background
colour, white.
PHP: the $borderColor of setBorder() and the $color of
setBackground(), which Imagick parses with QueryColorCompliance.
use utopia_image::Color;
assert_eq!(Color::parse("#ff000080")?, Color::rgba(255, 0, 0, 128));
assert_eq!(Color::parse("red")?, Color::rgba(255, 0, 0, 255));
assert!(Color::parse("notacolor").is_err());$pixel = new \ImagickPixel('#ff000080');
print_r($pixel->getColor(1)); // r 1, g 0, b 0, a 0.5Tuple Fields§
§0: [u8; 4]Implementations§
Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Forget for Color
impl Freeze for Color
impl Move for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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 more