[−][src]Struct blush::Color
The representation of a color.
Note:
- Colors outside the sRGB gamut (which cannot be displayed on a typical
computer screen) can not be represented by
Color
. - The
PartialEq
instance compares twoColor
s by comparing their (integer) RGB values. This is different from comparing the HSL values. For example, HSL has many different representations of black (arbitrary hue and saturation values).
Implementations
impl Color
[src]
pub fn from_hsla(hue: f64, saturation: f64, lightness: f64, alpha: f64) -> Color
[src]
pub fn from_hsl(hue: f64, saturation: f64, lightness: f64) -> Color
[src]
pub fn from_rgba(r: u8, g: u8, b: u8, alpha: f64) -> Color
[src]
Create a Color
from integer RGB values between 0 and 255 and a floating
point alpha value between 0.0 and 1.0.
pub fn from_rgb(r: u8, g: u8, b: u8) -> Color
[src]
Create a Color
from integer RGB values between 0 and 255.
pub fn from_rgba_float(r: f64, g: f64, b: f64, alpha: f64) -> Color
[src]
Create a Color
from RGB and alpha values between 0.0 and 1.0. Values outside this range
will be clamped.
pub fn from_rgb_float(r: f64, g: f64, b: f64) -> Color
[src]
Create a Color
from RGB values between 0.0 and 1.0. Values outside this range will be
clamped.
pub fn from_xyz(x: f64, y: f64, z: f64, alpha: f64) -> Color
[src]
Create a Color
from XYZ coordinates in the CIE 1931 color space. Note that a Color
always represents a color in the sRGB gamut (colors that can be represented on a typical
computer screen) while the XYZ color space is bigger. This function will tend to create
fully saturated colors at the edge of the sRGB gamut if the coordinates lie outside the
sRGB range.
See:
- https://en.wikipedia.org/wiki/CIE_1931_color_space
- https://en.wikipedia.org/wiki/SRGB
pub fn from_lms(l: f64, m: f64, s: f64, alpha: f64) -> Color
[src]
Create a Color
from LMS coordinates. This is the matrix inverse of the matrix that
appears in to_lms
.
pub fn from_lab(l: f64, a: f64, b: f64, alpha: f64) -> Color
[src]
Create a Color
from L, a and b coordinates coordinates in the Lab color
space. Note: See documentation for from_xyz
. The same restrictions apply here.
See: https://en.wikipedia.org/wiki/Lab_color_space
pub fn from_lch(l: f64, c: f64, h: f64, alpha: f64) -> Color
[src]
Create a Color
from lightness, chroma and hue coordinates in the CIE LCh color space.
This is a cylindrical transform of the Lab color space. Note: See documentation for
from_xyz
. The same restrictions apply here.
See: https://en.wikipedia.org/wiki/Lab_color_space
pub fn from_cmyk(c: f64, m: f64, y: f64, k: f64) -> Color
[src]
Create a Color
from the four colours of the CMYK model: Cyan, Magenta, Yellow and Black.
The CMYK colours are subtractive. This means the colours get darker as you blend them together
pub fn from_hex(hex_string: &str) -> Color
[src]
Create a Color
from HEX string. Shoud be exactly 6 chars or 7 with leading '#'
pub fn to_hsla(&self) -> HSLA
[src]
Convert a Color
to its hue, saturation, lightness and alpha values. The hue is given
in degrees, as a number between 0.0 and 360.0. Saturation, lightness and alpha are numbers
between 0.0 and 1.0.
pub fn to_hsl_string(&self, format: Format) -> String
[src]
Format the color as a HSL-representation string (hsl(123, 50.3%, 80.1%)
).
pub fn to_rgba(&self) -> RGBA<u8>
[src]
Convert a Color
to its red, green, blue and alpha values. The RGB values are integers in
the range from 0 to 255. The alpha channel is a number between 0.0 and 1.0.
pub fn to_rgb_string(&self, format: Format) -> String
[src]
Format the color as a RGB-representation string (rgb(255, 127, 0)
).
pub fn to_cmyk(&self) -> CMYK
[src]
Convert a Color
to its cyan, magenta, yellow, and black values. The CMYK
values are floats smaller than or equal to 1.0.
pub fn to_cmyk_string(&self, format: Format) -> String
[src]
Format the color as a CMYK-representation string (cmyk(0, 50, 100, 100)
).
pub fn to_rgb_float_string(&self, format: Format) -> String
[src]
Format the color as a floating point RGB-representation string (rgb(1.0, 0.5, 0)
).
pub fn to_rgb_hex_string(&self, leading_hash: bool) -> String
[src]
Format the color as a RGB-representation string (#fc0070
).
pub fn to_rgba_float(&self) -> RGBA<f64>
[src]
Convert a Color
to its red, green, blue and alpha values. All numbers are from the range
between 0.0 and 1.0.
pub fn to_u32(&self) -> u32
[src]
Return the color as an integer in RGB representation (0xRRGGBB
)
pub fn to_xyz(&self) -> XYZ
[src]
Get XYZ coordinates according to the CIE 1931 color space.
See:
- https://en.wikipedia.org/wiki/CIE_1931_color_space
- https://en.wikipedia.org/wiki/SRGB
pub fn to_lms(&self) -> LMS
[src]
Get coordinates according to the LSM color space
See https://en.wikipedia.org/wiki/LMS_color_space for info on the color space as well as an algorithm for converting from CIE XYZ
pub fn to_hex(&self) -> HEX
[src]
Convert a Color
to its a HEX color. It converts to RGBA as intermediary then to HEX
pub fn to_lab(&self) -> Lab
[src]
Get L, a and b coordinates according to the Lab color space.
See: https://en.wikipedia.org/wiki/Lab_color_space
pub fn to_lab_string(&self, format: Format) -> String
[src]
Format the color as a Lab-representation string (Lab(41, 83, -93)
).
pub fn to_lch(&self) -> LCh
[src]
Get L, C and h coordinates according to the CIE LCh color space.
See: https://en.wikipedia.org/wiki/Lab_color_space
pub fn to_lch_string(&self, format: Format) -> String
[src]
Format the color as a LCh-representation string (LCh(0.3, 0.2, 0.1)
).
pub fn black() -> Color
[src]
Pure black.
pub fn white() -> Color
[src]
Pure white.
pub fn red() -> Color
[src]
Red (#ff0000
)
pub fn green() -> Color
[src]
Green (#008000
)
pub fn blue() -> Color
[src]
Blue (#0000ff
)
pub fn yellow() -> Color
[src]
Yellow (#ffff00
)
pub fn fuchsia() -> Color
[src]
Fuchsia (#ff00ff
)
pub fn aqua() -> Color
[src]
Aqua (#00ffff
)
pub fn lime() -> Color
[src]
Lime (#00ff00
)
pub fn maroon() -> Color
[src]
Maroon (#800000
)
pub fn olive() -> Color
[src]
Olive (#808000
)
pub fn navy() -> Color
[src]
Navy (#000080
)
pub fn purple() -> Color
[src]
Purple (#800080
)
pub fn teal() -> Color
[src]
Teal (#008080
)
pub fn silver() -> Color
[src]
Silver (#c0c0c0
)
pub fn gray() -> Color
[src]
Gray (#808080
)
pub fn graytone(lightness: f64) -> Color
[src]
Create a gray tone from a lightness value (0.0 is black, 1.0 is white).
pub fn rotate_hue(&self, delta: f64) -> Color
[src]
Rotate along the "hue" axis.
pub fn complementary(&self) -> Color
[src]
Get the complementary color (hue rotated by 180°).
pub fn lighten(&self, f: f64) -> Color
[src]
Lighten a color by adding a certain amount (number between -1.0 and 1.0) to the lightness channel. If the number is negative, the color is darkened.
pub fn darken(&self, f: f64) -> Color
[src]
Darken a color by subtracting a certain amount (number between -1.0 and 1.0) from the lightness channel. If the number is negative, the color is lightened.
pub fn saturate(&self, f: f64) -> Color
[src]
Increase the saturation of a color by adding a certain amount (number between -1.0 and 1.0) to the saturation channel. If the number is negative, the color is desaturated.
pub fn desaturate(&self, f: f64) -> Color
[src]
Decrease the saturation of a color by subtracting a certain amount (number between -1.0 and 1.0) from the saturation channel. If the number is negative, the color is saturated.
pub fn simulate_colorblindness(&self, cb_ty: ColorblindnessType) -> Color
[src]
Adjust the long-, medium-, and short-wavelength cone perception of a color to simulate what
a colorblind person sees. Since there are multiple kinds of colorblindness, the desired
kind must be specified in cb_ty
.
pub fn to_gray(&self) -> Color
[src]
Convert a color to a gray tone with the same perceived luminance (see luminance
).
pub fn brightness(&self) -> f64
[src]
The percieved brightness of the color (A number between 0.0 and 1.0).
See: https://www.w3.org/TR/AERT#color-contrast
pub fn is_light(&self) -> bool
[src]
Determine whether a color is perceived as a light color (perceived brightness is larger than 0.5).
pub fn luminance(&self) -> f64
[src]
The relative brightness of a color (normalized to 0.0 for darkest black and 1.0 for lightest white), according to the WCAG definition.
See: https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
pub fn contrast_ratio(&self, other: &Color) -> f64
[src]
Contrast ratio between two colors as defined by the WCAG. The ratio can range from 1.0 to 21.0. Two colors with a contrast ratio of 4.5 or higher can be used as text color and background color and should be well readable.
https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
pub fn text_color(&self) -> Color
[src]
Return a readable foreground text color (either black
or white
) for a
given background color.
pub fn distance_delta_e_cie76(&self, other: &Color) -> f64
[src]
Compute the perceived 'distance' between two colors according to the CIE76 delta-E standard. A distance below ~2.3 is not noticable.
See: https://en.wikipedia.org/wiki/Color_difference
pub fn distance_delta_e_ciede2000(&self, other: &Color) -> f64
[src]
Compute the perceived 'distance' between two colors according to the CIEDE2000 delta-E standard.
See: https://en.wikipedia.org/wiki/Color_difference
pub fn mix<C: ColorSpace>(
self: &Color,
other: &Color,
fraction: Fraction
) -> Color
[src]
self: &Color,
other: &Color,
fraction: Fraction
) -> Color
Mix two colors by linearly interpolating between them in the specified color space. For the angle-like components (hue), the shortest path along the unit circle is chosen.
Trait Implementations
impl Clone for Color
[src]
impl Debug for Color
[src]
impl Display for Color
[src]
impl From<&'_ CMYK> for Color
[src]
impl From<&'_ Color> for RGBA<f64>
[src]
impl From<&'_ Color> for RGBA<u8>
[src]
impl From<&'_ Color> for HSLA
[src]
impl From<&'_ Color> for XYZ
[src]
impl From<&'_ Color> for LMS
[src]
impl From<&'_ Color> for Lab
[src]
impl From<&'_ Color> for LCh
[src]
impl From<&'_ Color> for CMYK
[src]
impl From<&'_ Color> for HEX
[src]
impl From<&'_ HEX> for Color
[src]
impl From<&'_ HSLA> for Color
[src]
impl From<&'_ LCh> for Color
[src]
impl From<&'_ LMS> for Color
[src]
impl From<&'_ Lab> for Color
[src]
impl From<&'_ RGBA<f64>> for Color
[src]
impl From<&'_ RGBA<u8>> for Color
[src]
impl From<&'_ XYZ> for Color
[src]
impl PartialEq<Color> for Color
[src]
Auto Trait Implementations
impl RefUnwindSafe for Color
[src]
impl Send for Color
[src]
impl Sync for Color
[src]
impl Unpin for Color
[src]
impl UnwindSafe for Color
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,