cosmic::cosmic_theme::palette

Struct Alpha

Source
#[repr(C)]
pub struct Alpha<C, T> { pub color: C, pub alpha: T, }
Expand description

An alpha component wrapper for colors, for adding transparency.

Instead of having separate types for “RGB with alpha”, “HSV with alpha”, and so on, Palette uses this wrapper type to attach the alpha component. The memory representation is the same as if alpha was the last member/property of color, which is just as space efficient. The perk of having a wrapper is that the alpha can easily be added to or separated form any color.

§Creating Transparent Values

The color types in Palette have transparent type aliases, such as Srgba for Srgb or Hsla for Hsl. These aliases implement new and other useful methods. Here’s the same example as for Rgb, but with transparency:

use palette::Srgba;

let rgba_u8 = Srgba::new(171u8, 193, 35, 128);
let rgab_f32 = Srgba::new(0.3f32, 0.8, 0.1, 0.5);

// `new` is also `const`:
const RGBA_U8: Srgba<u8> = Srgba::new(171, 193, 35, 128);

// Conversion methods from the color type are usually available for transparent
// values too. For example `into_format` for changing the number format:
let rgb_u8_from_f32 = Srgba::new(0.3f32, 0.8, 0.1, 0.5).into_format::<u8, u8>();

// Hexadecimal is also supported for RGBA, with or without the #:
let rgb_from_hex1: Srgba<u8> = "#f034e65a".parse().unwrap();
let rgb_from_hex2: Srgba<u8> = "f034e65a".parse().unwrap();
assert_eq!(rgb_from_hex1, rgb_from_hex2);

// This includes the shorthand format:
let rgb_from_short_hex: Srgba<u8> = "f3ea".parse().unwrap();
let rgb_from_long_hex: Srgba<u8> = "ff33eeaa".parse().unwrap();
assert_eq!(rgb_from_short_hex, rgb_from_long_hex);

// It's also possible to convert from (and to) arrays, tuples and `u32` values:
let rgb_from_array = Srgba::from([171u8, 193, 35, 128]);
let rgb_from_tuple = Srgba::from((171u8, 193, 35, 128));
let rgb_from_u32 = Srgba::from(0x607F005A);

Opaque values can be made transparent using the WithAlpha trait, in addition to simply wrapping them in Alpha. WithAlpha is also useful in generic code, since it’s implemented for both opaque and transparent types.

use palette::{WithAlpha, Srgb};

let rgb = Srgb::new(171u8, 193, 35);
let rgba = rgb.with_alpha(128u8);
assert_eq!(rgba.alpha, 128);

You may have noticed the u8 in rgb.with_alpha(128u8). That’s because Alpha allows the transparency component to have a different type than the color components. It would be just as valid to write rgb.with_alpha(0.5f32), for example.

§Accessing Color Components

To help with the nesting, Alpha implements Deref and DerefMut. This use of the traits is a bit unconventional, since Alpha isn’t a smart pointer. It turned out to be a quite successful experiment that stuck around.

use palette::Srgba;

let rgba = Srgba::new(171u8, 193, 35, 128);
let red = rgba.red; // Accesses `rgba.color.red`.
let alpha = rgba.alpha; // Accesses `rgba.alpha`.
let rgb = rgba.color; // Accesses `rgba.color`;

The main drawback is in generic code:

use palette::Srgba;

fn get_red<T>(rgba: Srgba<T>) -> T {
    rgba.red // Error: cannot move out of dereference of `Alpha<Rgb<_, T>, T>`
}

red has to be accessed through color:

use palette::Srgba;

fn get_red<T>(rgba: Srgba<T>) -> T {
    rgba.color.red
}

Fields§

§color: C

The color.

§alpha: T

The transparency component. 0.0 (or 0u8) is fully transparent and 1.0 (or 255u8) is fully opaque.

Implementations§

Source§

impl<C, A> Alpha<C, A>

Source

pub fn iter<'a>(&'a self) -> <&'a Alpha<C, A> as IntoIterator>::IntoIter
where &'a Alpha<C, A>: IntoIterator,

Return an iterator over the colors in the wrapped collections.

Source

pub fn iter_mut<'a>( &'a mut self, ) -> <&'a mut Alpha<C, A> as IntoIterator>::IntoIter
where &'a mut Alpha<C, A>: IntoIterator,

Return an iterator that allows modifying the colors in the wrapped collections.

Source§

impl<C> Alpha<C, <C as Premultiply>::Scalar>
where C: Premultiply,

Source

pub fn premultiply(self) -> PreAlpha<C>

Alpha mask the color by its transparency.

Source§

impl<C, T> Alpha<C, T>
where T: Stimulus,

Source

pub fn min_alpha() -> T

Return the alpha value minimum.

Source

pub fn max_alpha() -> T

Return the alpha value maximum.

Source§

impl<T, A> Alpha<Cam16<T>, A>

Cam16a implementations.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive CIE CAM16 attributes with transparency for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, that matches these CIE CAM16 attributes, under the provided viewing conditions.

This assumes that all of the correlated attributes are consistent, as only some of them are actually used. You may want to use one of the partial CAM16 representations for more control over which set of attributes that should be.

use palette::{Srgba, FromColor, cam16::{Cam16a, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let cam16a = get_cam16a_value();
let rgba = Srgba::from_color(cam16a.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16a, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let cam16a = get_cam16a_value();
let rgba = Srgba::from_color(cam16a.into_xyz(baked_parameters));
Source§

impl<T, A> Alpha<Cam16Jch<T>, A>

Cam16Jcha implementations.

Source

pub fn new<H>( lightness: T, chroma: T, hue: H, alpha: A, ) -> Alpha<Cam16Jch<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( lightness: T, chroma: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Jch<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Jch::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (lightness, chroma, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Jch<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (lightness, chroma, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Jch<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Jch<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Jcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jcha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Jcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jcha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Jch<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Jcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Jcha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Jcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Jcha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Jch<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Jcha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Jch<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Jcha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Jcha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Jch<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Jch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Jch<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Jch<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Jch<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Jch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Jch<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Jch<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Jch<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Jch<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Jch<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Jch<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Jch<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16Jmh<T>, A>

Cam16Jmha implementations.

Source

pub fn new<H>( lightness: T, colorfulness: T, hue: H, alpha: A, ) -> Alpha<Cam16Jmh<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( lightness: T, colorfulness: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Jmh<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Jmh::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (lightness, colorfulness, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Jmh<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (lightness, colorfulness, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Jmh<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Jmh<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Jmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jmha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Jmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jmha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Jmh<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Jmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Jmha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Jmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Jmha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Jmh<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Jmha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Jmh<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Jmha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Jmha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Jmh<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Jmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Jmh<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Jmh<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Jmh<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Jmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Jmh<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Jmh<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Jmh<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Jmh<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Jmh<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Jmh<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Jmh<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16Jsh<T>, A>

Cam16Jsha implementations.

Source

pub fn new<H>( lightness: T, saturation: T, hue: H, alpha: A, ) -> Alpha<Cam16Jsh<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( lightness: T, saturation: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Jsh<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Jsh::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (lightness, saturation, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Jsh<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (lightness, saturation, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Jsh<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Jsh<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Jsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jsha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Jsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Jsha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Jsh<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Jsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Jsha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Jsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Jsha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Jsh<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Jsha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Jsh<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Jsha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Jsha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Jsh<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Jsh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jsh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Jsh<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Jsh<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Jsh<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Jsh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Jsh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Jsh<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Jsh<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Jsh<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Jsh<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Jsh<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Jsh<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Jsh<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16Qch<T>, A>

Cam16Qcha implementations.

Source

pub fn new<H>( brightness: T, chroma: T, hue: H, alpha: A, ) -> Alpha<Cam16Qch<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( brightness: T, chroma: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Qch<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Qch::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (brightness, chroma, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Qch<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (brightness, chroma, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Qch<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Qch<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Qcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qcha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Qcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qcha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Qch<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Qcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Qcha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Qcha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Qcha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Qch<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Qcha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Qch<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Qcha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Qcha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Qch<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Qch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Qch<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Qch<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Qch<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Qch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Qch<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Qch<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Qch<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Qch<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Qch<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Qch<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Qch<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16Qmh<T>, A>

Cam16Qmha implementations.

Source

pub fn new<H>( brightness: T, colorfulness: T, hue: H, alpha: A, ) -> Alpha<Cam16Qmh<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( brightness: T, colorfulness: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Qmh<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Qmh::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (brightness, colorfulness, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Qmh<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (brightness, colorfulness, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Qmh<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Qmh<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Qmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qmha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Qmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qmha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Qmh<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Qmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Qmha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Qmha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Qmha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Qmh<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Qmha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Qmh<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Qmha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Qmha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Qmh<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Qmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Qmh<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Qmh<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Qmh<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Qmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Qmh<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Qmh<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Qmh<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Qmh<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Qmh<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Qmh<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Qmh<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16Qsh<T>, A>

Cam16Qsha implementations.

Source

pub fn new<H>( brightness: T, saturation: T, hue: H, alpha: A, ) -> Alpha<Cam16Qsh<T>, A>
where H: Into<Cam16Hue<T>>,

Create a partial CIE CAM16 color with transparency.

Source

pub const fn new_const( brightness: T, saturation: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16Qsh<T>, A>

Create a partial CIE CAM16 color with transparency. This is the same as Cam16Qsh::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (brightness, saturation, hue, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16Qsh<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (brightness, saturation, hue, alpha) tuple.

Source

pub fn from_xyz<WpParam>( color: Alpha<Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>, A>, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16Qsh<T>, A>
where Xyz<<WpParam as WhitePointParameter<<T as FromScalar>::Scalar>>::StaticWp, T>: IntoCam16Unclamped<WpParam, Cam16Qsh<T>, Scalar = <T as FromScalar>::Scalar>, T: FromScalar, WpParam: WhitePointParameter<<T as FromScalar>::Scalar>,

Derive partial CIE CAM16 attributes with transparency, for the provided color, under the provided viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16Qsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qsha::from_xyz(rgba.into_color(), example_parameters);

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, IntoColor, cam16::{Cam16Qsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f32, 0.8, 0.1, 0.9);
let partial = Cam16Qsha::from_xyz(rgba.into_color(), baked_parameters);
Source

pub fn into_xyz<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, A>
where Cam16Qsh<T>: Cam16IntoUnclamped<WpParam, Xyz<<WpParam as WhitePointParameter<T>>::StaticWp, T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Construct an XYZ color with transparency, from these CIE CAM16 attributes, under the provided viewing conditions.

use palette::{Srgba, FromColor, cam16::{Cam16Qsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let partial = Cam16Qsha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(example_parameters));

It’s also possible to “pre-bake” the parameters, to avoid recalculate some of the derived values when converting multiple color value.

use palette::{Srgba, FromColor, cam16::{Cam16Qsha, Parameters}};

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

let baked_parameters = example_parameters.bake();

let partial = Cam16Qsha::new(50.0f32, 80.0, 120.0, 0.9);
let rgba = Srgba::from_color(partial.into_xyz(baked_parameters));
Source

pub fn from_full(full: Alpha<Cam16<T>, A>) -> Alpha<Cam16Qsh<T>, A>

Create a partial set of CIE CAM16 attributes with transparency.

It’s also possible to use Cam16Qsha::from or Cam16a::into.

Source

pub fn into_full<WpParam>( self, parameters: impl Into<BakedParameters<WpParam, <T as FromScalar>::Scalar>>, ) -> Alpha<Cam16<T>, A>
where Cam16Qsh<T>: IntoCam16Unclamped<WpParam, Cam16<T>, Scalar = <T as FromScalar>::Scalar>, WpParam: WhitePointParameter<T>, T: FromScalar,

Reconstruct a full set of CIE CAM16 attributes with transparency, using the original viewing conditions.

use palette::{Srgba, IntoColor, cam16::{Cam16a, Cam16Qsha, Parameters}};
use approx::assert_relative_eq;

// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);

// Optional, but saves some work:
let baked_parameters = example_parameters.bake();

let rgba = Srgba::new(0.3f64, 0.8, 0.1, 0.9);
let cam16a = Cam16a::from_xyz(rgba.into_color(), baked_parameters);
let partial = Cam16Qsha::from(cam16a);
let reconstructed = partial.into_full(baked_parameters);

assert_relative_eq!(cam16a, reconstructed, epsilon = 0.0000000000001);
Source§

impl<T, A> Alpha<Cam16Qsh<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16Qsh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qsh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16Qsh<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16Qsh<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16Qsh<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16Qsh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16Qsh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16Qsh<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16Qsh<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16Qsh<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16Qsh<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16Qsh<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16Qsh<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16Qsh<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16UcsJab<T>, A>

Cam16UcsJaba implementations.

Source

pub const fn new(lightness: T, a: T, b: T, alpha: A) -> Alpha<Cam16UcsJab<T>, A>

Create a CAM16-UCS J’ a’ b’ color with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (J', a', b', a) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Cam16UcsJab<T>, A>

Convert from a (J', a', b', a) tuple.

Source§

impl<T, A> Alpha<Cam16UcsJab<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16UcsJab<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16UcsJab<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16UcsJab<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16UcsJab<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16UcsJab<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16UcsJab<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16UcsJab<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16UcsJab<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16UcsJab<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16UcsJab<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16UcsJab<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16UcsJab<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16UcsJab<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16UcsJab<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Cam16UcsJmh<T>, A>

Cam16UcsJmha implementations.

Source

pub fn new<H>( lightness: T, colorfulness: T, hue: H, alpha: A, ) -> Alpha<Cam16UcsJmh<T>, A>
where H: Into<Cam16Hue<T>>,

Create a CAM16-UCS J’ M’ h’ color with transparency.

Source

pub const fn new_const( lightness: T, colorfulness: T, hue: Cam16Hue<T>, alpha: A, ) -> Alpha<Cam16UcsJmh<T>, A>

Create a CAM16-UCS J’ M’ h’ color with transparency. This is the same as Cam16UcsJmha::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, Cam16Hue<T>, A)

Convert to a (J', M', h', a) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Cam16UcsJmh<T>, A>
where H: Into<Cam16Hue<T>>,

Convert from a (J', M', h', a) tuple.

Source§

impl<T, A> Alpha<Cam16UcsJmh<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Cam16UcsJmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16UcsJmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Cam16UcsJmh<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Cam16UcsJmh<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Cam16UcsJmh<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Cam16UcsJmh<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Cam16UcsJmh<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Cam16UcsJmh<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Cam16UcsJmh<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Cam16UcsJmh<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Cam16UcsJmh<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Cam16UcsJmh<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Cam16UcsJmh<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Cam16UcsJmh<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Hsl<Srgb, T>, A>

Hsla implementations.

Source

pub fn new_srgb<H>( hue: H, saturation: T, lightness: T, alpha: A, ) -> Alpha<Hsl<Srgb, T>, A>
where H: Into<RgbHue<T>>,

Create an sRGB HSL color with transparency. This method can be used instead of Hsla::new to help type inference.

Source

pub const fn new_srgb_const( hue: RgbHue<T>, saturation: T, lightness: T, alpha: A, ) -> Alpha<Hsl<Srgb, T>, A>

Create an sRGB HSL color with transparency. This is the same as Hsla::new_srgb without the generic hue type. It’s temporary until const fn supports traits.

Source§

impl<S, T, A> Alpha<Hsl<S, T>, A>

Hsla implementations.

Source

pub fn new<H>( hue: H, saturation: T, lightness: T, alpha: A, ) -> Alpha<Hsl<S, T>, A>
where H: Into<RgbHue<T>>,

Create an HSL color with transparency.

Source

pub const fn new_const( hue: RgbHue<T>, saturation: T, lightness: T, alpha: A, ) -> Alpha<Hsl<S, T>, A>

Create an HSL color with transparency. This is the same as Hsla::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Hsl<S, U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Hsl<S, U>, B>) -> Alpha<Hsl<S, T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (RgbHue<T>, T, T, A)

Convert to a (hue, saturation, lightness, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Hsl<S, T>, A>
where H: Into<RgbHue<T>>,

Convert from a (hue, saturation, lightness, alpha) tuple.

Source§

impl<S, T, A> Alpha<Hsl<S, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Hsl<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsl<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, T, A> Alpha<Hsl<S, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Hsl<S, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Hsl<S, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Hsl<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsl<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, Ct, Ca> Alpha<Hsl<S, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Hsl<S, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Hsl<S, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<S, T, A> Alpha<Hsl<S, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Hsl<S, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Hsl<S, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Hsl<S, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, S>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Hsluv<Wp, T>, A>

Hsluva implementations.

Source

pub fn new<H>(hue: H, saturation: T, l: T, alpha: A) -> Alpha<Hsluv<Wp, T>, A>
where H: Into<LuvHue<T>>,

Create an HSLuv color with transparency.

Source

pub const fn new_const( hue: LuvHue<T>, saturation: T, l: T, alpha: A, ) -> Alpha<Hsluv<Wp, T>, A>

Create an HSLuv color with transparency. This is the same as Hsluva::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (LuvHue<T>, T, T, A)

Convert to a (hue, saturation, l, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Hsluv<Wp, T>, A>
where H: Into<LuvHue<T>>,

Convert from a (hue, saturation, l, alpha) tuple.

Source§

impl<Wp, T, A> Alpha<Hsluv<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Hsluv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsluv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Hsluv<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Hsluv<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Hsluv<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Hsluv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsluv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Hsluv<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Hsluv<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Hsluv<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Hsluv<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Hsluv<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Hsluv<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Hsluv<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Hsv<Srgb, T>, A>

Hsva implementations.

Source

pub fn new_srgb<H>( hue: H, saturation: T, value: T, alpha: A, ) -> Alpha<Hsv<Srgb, T>, A>
where H: Into<RgbHue<T>>,

Create an sRGB HSV color with transparency. This method can be used instead of Hsva::new to help type inference.

Source

pub const fn new_srgb_const( hue: RgbHue<T>, saturation: T, value: T, alpha: A, ) -> Alpha<Hsv<Srgb, T>, A>

Create an sRGB HSV color with transparency. This is the same as Hsva::new_srgb without the generic hue type. It’s temporary until const fn supports traits.

Source§

impl<S, T, A> Alpha<Hsv<S, T>, A>

Hsva implementations.

Source

pub fn new<H>(hue: H, saturation: T, value: T, alpha: A) -> Alpha<Hsv<S, T>, A>
where H: Into<RgbHue<T>>,

Create an HSV color with transparency.

Source

pub const fn new_const( hue: RgbHue<T>, saturation: T, value: T, alpha: A, ) -> Alpha<Hsv<S, T>, A>

Create an HSV color with transparency. This is the same as Hsva::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Hsv<S, U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Hsv<S, U>, B>) -> Alpha<Hsv<S, T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (RgbHue<T>, T, T, A)

Convert to a (hue, saturation, value, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Hsv<S, T>, A>
where H: Into<RgbHue<T>>,

Convert from a (hue, saturation, value, alpha) tuple.

Source§

impl<S, T, A> Alpha<Hsv<S, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Hsv<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsv<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, T, A> Alpha<Hsv<S, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Hsv<S, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Hsv<S, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Hsv<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hsv<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, Ct, Ca> Alpha<Hsv<S, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Hsv<S, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Hsv<S, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<S, T, A> Alpha<Hsv<S, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Hsv<S, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Hsv<S, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Hsv<S, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, S>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Hwb<Srgb, T>, A>

Hwba implementations.

Source

pub fn new_srgb<H>( hue: H, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Hwb<Srgb, T>, A>
where H: Into<RgbHue<T>>,

Create an sRGB HWB color with transparency. This method can be used instead of Hwba::new to help type inference.

Source

pub const fn new_srgb_const( hue: RgbHue<T>, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Hwb<Srgb, T>, A>

Create an sRGB HWB color with transparency. This is the same as Hwba::new_srgb without the generic hue type. It’s temporary until const fn supports traits.

Source§

impl<S, T, A> Alpha<Hwb<S, T>, A>

Hwba implementations.

Source

pub fn new<H>( hue: H, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Hwb<S, T>, A>
where H: Into<RgbHue<T>>,

Create an HWB color with transparency.

Source

pub const fn new_const( hue: RgbHue<T>, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Hwb<S, T>, A>

Create an HWB color with transparency. This is the same as Hwba::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Hwb<S, U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Hwb<S, U>, B>) -> Alpha<Hwb<S, T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (RgbHue<T>, T, T, A)

Convert to a (hue, whiteness, blackness, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Hwb<S, T>, A>
where H: Into<RgbHue<T>>,

Convert from a (hue, whiteness, blackness, alpha) tuple.

Source§

impl<S, T, A> Alpha<Hwb<S, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Hwb<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hwb<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, T, A> Alpha<Hwb<S, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Hwb<S, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Hwb<S, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Hwb<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Hwb<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, Ct, Ca> Alpha<Hwb<S, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Hwb<S, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Hwb<S, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<S, T, A> Alpha<Hwb<S, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Hwb<S, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Hwb<S, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Hwb<S, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, S>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Lab<Wp, T>, A>

Laba implementations.

Source

pub const fn new(l: T, a: T, b: T, alpha: A) -> Alpha<Lab<Wp, T>, A>

Create a CIE L*a*b* with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (L\*, a\*, b\*, alpha) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Lab<Wp, T>, A>

Convert from a (L\*, a\*, b\*, alpha) tuple.

Source§

impl<Wp, T, A> Alpha<Lab<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Lab<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lab<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Lab<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Lab<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Lab<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Lab<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lab<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Lab<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Lab<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Lab<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Lab<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Lab<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Lab<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Lab<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Lch<Wp, T>, A>

Lcha implementations.

Source

pub fn new<H>(l: T, chroma: T, hue: H, alpha: A) -> Alpha<Lch<Wp, T>, A>
where H: Into<LabHue<T>>,

Create a CIE L*C*h° color with transparency.

Source

pub const fn new_const( l: T, chroma: T, hue: LabHue<T>, alpha: A, ) -> Alpha<Lch<Wp, T>, A>

Create a CIE L*C*h° color with transparency. This is the same as Lcha::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, LabHue<T>, A)

Convert to a (L\*, C\*, h°, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Lch<Wp, T>, A>
where H: Into<LabHue<T>>,

Convert from a (L\*, C\*, h°, alpha) tuple.

Source§

impl<Wp, T, A> Alpha<Lch<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Lch<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lch<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Lch<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Lch<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Lch<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Lch<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lch<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Lch<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Lch<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Lch<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Lch<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Lch<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Lch<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Lch<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Lchuv<Wp, T>, A>

Lchuva implementations.

Source

pub fn new<H>(l: T, chroma: T, hue: H, alpha: A) -> Alpha<Lchuv<Wp, T>, A>
where H: Into<LuvHue<T>>,

Create a CIE L*C*uv h°uv color with transparency.

Source

pub const fn new_const( l: T, chroma: T, hue: LuvHue<T>, alpha: A, ) -> Alpha<Lchuv<Wp, T>, A>

Create a CIE L*C*uv h°uv color with transparency. This is the same as Lchuva::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, LuvHue<T>, A)

Convert to a (L\*, C\*uv, h°uv, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Lchuv<Wp, T>, A>
where H: Into<LuvHue<T>>,

Convert from a (L\*, C\*uv, h°uv, alpha) tuple.

Source§

impl<Wp, T, A> Alpha<Lchuv<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Lchuv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lchuv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Lchuv<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Lchuv<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Lchuv<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Lchuv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Lchuv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Lchuv<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Lchuv<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Lchuv<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Lchuv<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Lchuv<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Lchuv<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Lchuv<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<S, T, A> Alpha<Luma<S, T>, A>

Lumaa implementations.

Source

pub const fn new(luma: T, alpha: A) -> Alpha<Luma<S, T>, A>

Create a luminance color with transparency.

Source

pub fn into_format<U, B>(self) -> Alpha<Luma<S, U>, B>
where U: FromStimulus<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Luma<S, U>, B>) -> Alpha<Luma<S, T>, A>
where T: FromStimulus<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (T, A)

Convert to a (luma, alpha) tuple.

Source

pub fn from_components(_: (T, A)) -> Alpha<Luma<S, T>, A>

Convert from a (luma, alpha) tuple.

Source§

impl<S> Alpha<Luma<S, u8>, u8>

Source

pub fn into_u16<O>(self) -> u16
where O: ComponentOrder<Alpha<Luma<S, u8>, u8>, u16>,

Convert to a packed u16 with with a specific component order.

use palette::{luma, SrgbLumaa};

let integer = SrgbLumaa::new(96u8, 255).into_u16::<luma::channels::Al>();
assert_eq!(0xFF60, integer);

It’s also possible to use From and Into, which defaults to the 0xLLAA component order:

use palette::SrgbLumaa;

let integer = u16::from(SrgbLumaa::new(96u8, 255));
assert_eq!(0x60FF, integer);

See Packed for more details.

Source

pub fn from_u16<O>(color: u16) -> Alpha<Luma<S, u8>, u8>
where O: ComponentOrder<Alpha<Luma<S, u8>, u8>, u16>,

Convert from a packed u16 with a specific component order.

use palette::{luma, SrgbLumaa};

let luma = SrgbLumaa::from_u16::<luma::channels::Al>(0xFF60);
assert_eq!(SrgbLumaa::new(96u8, 255), luma);

It’s also possible to use From and Into, which defaults to the 0xLLAA component order:

use palette::SrgbLumaa;

let luma = SrgbLumaa::from(0x60FF);
assert_eq!(SrgbLumaa::new(96u8, 255), luma);

See Packed for more details.

Source§

impl<S, T, A> Alpha<Luma<S, T>, A>
where S: LumaStandard,

Source

pub fn into_linear<U, B>( self, ) -> Alpha<Luma<Linear<<S as LumaStandard>::WhitePoint>, U>, B>
where <S as LumaStandard>::TransferFn: IntoLinear<U, T>, B: FromStimulus<A>,

Convert the color to linear luminance with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{SrgbLumaa, LinLumaa};

let linear: LinLumaa<_, f32> = SrgbLumaa::new(96u8, 38).into_linear();

See the transfer function types in the encoding module for details and performance characteristics.

Source

pub fn from_linear<U, B>( color: Alpha<Luma<Linear<<S as LumaStandard>::WhitePoint>, U>, B>, ) -> Alpha<Luma<S, T>, A>
where <S as LumaStandard>::TransferFn: FromLinear<U, T>, A: FromStimulus<B>,

Convert linear luminance to non-linear luminance with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{SrgbLumaa, LinLumaa};

let encoded = SrgbLumaa::<u8>::from_linear(LinLumaa::new(0.95f32, 0.75));

See the transfer function types in the encoding module for details and performance characteristics.

Source§

impl<Wp, T, A> Alpha<Luma<Linear<Wp>, T>, A>

Source

pub fn into_encoding<U, B, St>(self) -> Alpha<Luma<St, U>, B>
where St: LumaStandard<WhitePoint = Wp>, <St as LumaStandard>::TransferFn: FromLinear<T, U>, B: FromStimulus<A>,

Convert a linear color to a different encoding with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{SrgbLumaa, LinLumaa};

let encoded: SrgbLumaa<u8> = LinLumaa::new(0.95f32, 0.75).into_encoding();

See the transfer function types in the encoding module for details and performance characteristics.

Source

pub fn from_encoding<U, B, St>( color: Alpha<Luma<St, U>, B>, ) -> Alpha<Luma<Linear<Wp>, T>, A>
where St: LumaStandard<WhitePoint = Wp>, <St as LumaStandard>::TransferFn: IntoLinear<T, U>, A: FromStimulus<B>,

Convert to linear luminance from a different encoding with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{SrgbLumaa, LinLumaa};

let linear = LinLumaa::<_, f32>::from_encoding(SrgbLumaa::new(96u8, 38));

See the transfer function types in the encoding module for details and performance characteristics.

Source§

impl<S, T, A> Alpha<Luma<S, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Luma<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Luma<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, T, A> Alpha<Luma<S, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Luma<S, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Luma<S, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Luma<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Luma<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, Ct, Ca> Alpha<Luma<S, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Luma<S, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Luma<S, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<S, T, A> Alpha<Luma<S, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Luma<S, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Luma<S, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Luma<S, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, S>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Luv<Wp, T>, A>

Luva implementations.

Source

pub const fn new(l: T, u: T, v: T, alpha: A) -> Alpha<Luv<Wp, T>, A>

Create a CIE L*u*v* color with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to u (L\*, u\*, v\*, alpha) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Luv<Wp, T>, A>

Convert from u (L\*, u\*, v\*, alpha) tuple.

Source§

impl<Wp, T, A> Alpha<Luv<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Luv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Luv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Luv<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Luv<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Luv<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Luv<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Luv<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Luv<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Luv<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Luv<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Luv<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Luv<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Luv<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Luv<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Okhsl<T>, A>

Okhsla implementations.

Source

pub fn new<H>( hue: H, saturation: T, lightness: T, alpha: A, ) -> Alpha<Okhsl<T>, A>
where H: Into<OklabHue<T>>,

Create an Okhsl color with transparency.

Source

pub const fn new_const( hue: OklabHue<T>, saturation: T, lightness: T, alpha: A, ) -> Alpha<Okhsl<T>, A>

Create an Okhsla color. This is the same as Okhsla::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Okhsl<U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Okhsl<U>, B>) -> Alpha<Okhsl<T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (OklabHue<T>, T, T, A)

Convert to a (hue, saturation, lightness, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Okhsl<T>, A>
where H: Into<OklabHue<T>>,

Convert from a (hue, saturation, lightness, alpha) tuple.

Source§

impl<T, A> Alpha<Okhsl<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Okhsl<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhsl<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Okhsl<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Okhsl<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Okhsl<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Okhsl<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhsl<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Okhsl<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Okhsl<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Okhsl<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Okhsl<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Okhsl<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Okhsl<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Okhsl<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Okhsv<T>, A>

Hsva implementations.

Source

pub fn new<H>(hue: H, saturation: T, value: T, alpha: A) -> Alpha<Okhsv<T>, A>
where H: Into<OklabHue<T>>,

Create an Okhsv color with transparency.

Source

pub const fn new_const( hue: OklabHue<T>, saturation: T, value: T, alpha: A, ) -> Alpha<Okhsv<T>, A>

Create an Okhsva color. This is the same as Okhsva::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Okhsv<U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Okhsv<U>, B>) -> Alpha<Okhsv<T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>, U: Zero + MinMax,

Convert from another component type.

Source

pub fn into_components(self) -> (OklabHue<T>, T, T, A)

Convert to a (hue, saturation, value, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Okhsv<T>, A>
where H: Into<OklabHue<T>>,

Convert from a (hue, saturation, value, alpha) tuple.

Source§

impl<T, A> Alpha<Okhsv<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Okhsv<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhsv<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Okhsv<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Okhsv<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Okhsv<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Okhsv<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhsv<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Okhsv<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Okhsv<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Okhsv<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Okhsv<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Okhsv<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Okhsv<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Okhsv<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Okhwb<T>, A>

Okhwba implementations.

Source

pub fn new<H>( hue: H, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Okhwb<T>, A>
where H: Into<OklabHue<T>>,

Create an Okhwb color with transparency.

Source

pub const fn new_const( hue: OklabHue<T>, whiteness: T, blackness: T, alpha: A, ) -> Alpha<Okhwb<T>, A>

Create an Okhwba color. This is the same as Okhwba::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_format<U, B>(self) -> Alpha<Okhwb<U>, B>
where U: FromStimulus<T> + FromAngle<T>, B: FromStimulus<A>,

Convert into another component type.

Source

pub fn from_format<U, B>(color: Alpha<Okhwb<U>, B>) -> Alpha<Okhwb<T>, A>
where T: FromStimulus<U> + FromAngle<U>, A: FromStimulus<B>,

Convert from another component type.

Source

pub fn into_components(self) -> (OklabHue<T>, T, T, A)

Convert to a (hue, whiteness, blackness, alpha) tuple.

Source

pub fn from_components<H>(_: (H, T, T, A)) -> Alpha<Okhwb<T>, A>
where H: Into<OklabHue<T>>,

Convert from a (hue, whiteness, blackness, alpha) tuple.

Source§

impl<T, A> Alpha<Okhwb<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Okhwb<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhwb<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Okhwb<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Okhwb<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Okhwb<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Okhwb<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Okhwb<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Okhwb<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Okhwb<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Okhwb<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Okhwb<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Okhwb<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Okhwb<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Okhwb<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Oklab<T>, A>

Oklaba implementations.

Source

pub const fn new(l: T, a: T, b: T, alpha: A) -> Alpha<Oklab<T>, A>

Create an Oklab color with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (L, a, b, alpha) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Oklab<T>, A>

Convert from a (L, a, b, alpha) tuple.

Source§

impl<T, A> Alpha<Oklab<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Oklab<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Oklab<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Oklab<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Oklab<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Oklab<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Oklab<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Oklab<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Oklab<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Oklab<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Oklab<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Oklab<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Oklab<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Oklab<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Oklab<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<T, A> Alpha<Oklch<T>, A>

Oklcha implementations.

Source

pub fn new<H>(l: T, chroma: T, hue: H, alpha: A) -> Alpha<Oklch<T>, A>
where H: Into<OklabHue<T>>,

Create an Oklch color with transparency.

Source

pub const fn new_const( l: T, chroma: T, hue: OklabHue<T>, alpha: A, ) -> Alpha<Oklch<T>, A>

Create an Oklcha color. This is the same as Oklcha::new without the generic hue type. It’s temporary until const fn supports traits.

Source

pub fn into_components(self) -> (T, T, OklabHue<T>, A)

Convert to a (L, C, h, alpha) tuple.

Source

pub fn from_components<H>(_: (T, T, H, A)) -> Alpha<Oklch<T>, A>
where H: Into<OklabHue<T>>,

Convert from a (L, C, h, alpha) tuple.

Source§

impl<T, A> Alpha<Oklch<&T>, &A>

Source

pub fn copied(&self) -> Alpha<Oklch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Oklch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<T, A> Alpha<Oklch<&mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Oklch<T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Oklch<&T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Oklch<T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Oklch<T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Ct, Ca> Alpha<Oklch<Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Oklch<&'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Oklch<&'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<T, A> Alpha<Oklch<Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Oklch<Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Oklch<T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Oklch<T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>(&mut self, range: R) -> Iter<Iter<Drain<'_, T>>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<S, T, A> Alpha<Rgb<S, T>, A>

Rgba implementations.

Source

pub const fn new(red: T, green: T, blue: T, alpha: A) -> Alpha<Rgb<S, T>, A>

Non-linear RGB.

Source

pub fn into_format<U, B>(self) -> Alpha<Rgb<S, U>, B>
where U: FromStimulus<T>, B: FromStimulus<A>,

Convert the RGBA components into other number types.

use palette::Srgba;

let rgba_u8: Srgba<u8> = Srgba::new(0.3, 0.7, 0.2, 0.5).into_format();

See also into_linear and into_encoding for a faster option if you need to change between linear and non-linear encoding at the same time.

Source

pub fn from_format<U, B>(color: Alpha<Rgb<S, U>, B>) -> Alpha<Rgb<S, T>, A>
where T: FromStimulus<U>, A: FromStimulus<B>,

Convert the RGBA components from other number types.

use palette::Srgba;

let rgba_u8 = Srgba::<u8>::from_format(Srgba::new(0.3, 0.7, 0.2, 0.5));

See also from_linear and from_encoding for a faster option if you need to change between linear and non-linear encoding at the same time.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (red, green, blue, alpha) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Rgb<S, T>, A>

Convert from a (red, green, blue, alpha) tuple.

Source§

impl<S> Alpha<Rgb<S, u8>, u8>

Source

pub fn into_u32<O>(self) -> u32
where O: ComponentOrder<Alpha<Rgb<S, u8>, u8>, u32>,

Convert to a packed u32 with with specifiable component order.

use palette::{rgb, Srgba};

let integer = Srgba::new(96u8, 127, 0, 255).into_u32::<rgb::channels::Argb>();
assert_eq!(0xFF607F00, integer);

It’s also possible to use From and Into, which defaults to the 0xRRGGBBAA component order:

use palette::Srgba;

let integer = u32::from(Srgba::new(96u8, 127, 0, 255));
assert_eq!(0x607F00FF, integer);

See Packed for more details.

Source

pub fn from_u32<O>(color: u32) -> Alpha<Rgb<S, u8>, u8>
where O: ComponentOrder<Alpha<Rgb<S, u8>, u8>, u32>,

Convert from a packed u32 with specifiable component order.

use palette::{rgb, Srgba};

let rgba = Srgba::from_u32::<rgb::channels::Argb>(0xFF607F00);
assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);

It’s also possible to use From and Into, which defaults to the 0xRRGGBBAA component order:

use palette::Srgba;

let rgba = Srgba::from(0x607F00FF);
assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);

See Packed for more details.

Source§

impl<S, T, A> Alpha<Rgb<S, T>, A>
where S: RgbStandard,

Source

pub fn into_linear<U, B>( self, ) -> Alpha<Rgb<Linear<<S as RgbStandard>::Space>, U>, B>
where <S as RgbStandard>::TransferFn: IntoLinear<U, T>, B: FromStimulus<A>,

Convert the color to linear RGB with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{Srgba, LinSrgba};

let linear: LinSrgba<f32> = Srgba::new(96u8, 127, 0, 38).into_linear();

See the transfer function types in the encoding module for details and performance characteristics.

Source

pub fn from_linear<U, B>( color: Alpha<Rgb<Linear<<S as RgbStandard>::Space>, U>, B>, ) -> Alpha<Rgb<S, T>, A>
where <S as RgbStandard>::TransferFn: FromLinear<U, T>, A: FromStimulus<B>,

Convert linear RGB to non-linear RGB with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{Srgba, LinSrgba};

let encoded = Srgba::<u8>::from_linear(LinSrgba::new(0.95f32, 0.90, 0.30, 0.75));

See the transfer function types in the encoding module for details and performance characteristics.

Source§

impl<S, T, A> Alpha<Rgb<Linear<S>, T>, A>
where S: RgbSpace,

Source

pub fn into_encoding<U, B, St>(self) -> Alpha<Rgb<St, U>, B>
where St: RgbStandard<Space = S>, <St as RgbStandard>::TransferFn: FromLinear<T, U>, B: FromStimulus<A>,

Convert a linear color to a different encoding with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{Srgba, LinSrgba};

let encoded: Srgba<u8> = LinSrgba::new(0.95f32, 0.90, 0.30, 0.75).into_encoding();

See the transfer function types in the encoding module for details and performance characteristics.

Source

pub fn from_encoding<U, B, St>( color: Alpha<Rgb<St, U>, B>, ) -> Alpha<Rgb<Linear<S>, T>, A>
where St: RgbStandard<Space = S>, <St as RgbStandard>::TransferFn: IntoLinear<T, U>, A: FromStimulus<B>,

Convert RGB from a different encoding to linear with transparency.

Some transfer functions allow the component type to be converted at the same time. This is usually offered with increased performance, compared to using into_format.

use palette::{Srgba, LinSrgba};

let linear = LinSrgba::<f32>::from_encoding(Srgba::new(96u8, 127, 0, 38));

See the transfer function types in the encoding module for details and performance characteristics.

Source§

impl<S, T, A> Alpha<Rgb<S, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Rgb<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Rgb<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, T, A> Alpha<Rgb<S, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Rgb<S, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Rgb<S, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Rgb<S, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Rgb<S, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<S, Ct, Ca> Alpha<Rgb<S, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Rgb<S, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Rgb<S, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<S, T, A> Alpha<Rgb<S, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Rgb<S, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Rgb<S, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Rgb<S, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, S>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Xyz<Wp, T>, A>

Xyza implementations.

Source

pub const fn new(x: T, y: T, z: T, alpha: A) -> Alpha<Xyz<Wp, T>, A>

Create a CIE XYZ color with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (X, Y, Z, alpha) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Xyz<Wp, T>, A>

Convert from a (X, Y, Z, alpha) tuple.

Source

pub fn with_white_point<NewWp>(self) -> Alpha<Xyz<NewWp, T>, A>

Changes the reference white point without changing the color value.

This function doesn’t change the numerical values, and thus the color it represents in an absolute sense. However, the appearance of the color may not be the same when observed with the new white point. The effect would be similar to taking a photo with an incorrect white balance.

See chromatic_adaptation for operations that can change the white point while preserving the color’s appearance.

Source§

impl<Wp, T, A> Alpha<Xyz<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Xyz<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Xyz<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Xyz<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Xyz<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Xyz<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Xyz<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Xyz<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Xyz<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Xyz<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Xyz<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Xyz<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Xyz<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Xyz<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Xyz<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Source§

impl<Wp, T, A> Alpha<Yxy<Wp, T>, A>

Yxya implementations.

Source

pub const fn new(x: T, y: T, luma: T, alpha: A) -> Alpha<Yxy<Wp, T>, A>

Create a CIE Yxy color with transparency.

Source

pub fn into_components(self) -> (T, T, T, A)

Convert to a (x, y, luma), a.k.a. (x, y, Y) tuple.

Source

pub fn from_components(_: (T, T, T, A)) -> Alpha<Yxy<Wp, T>, A>

Convert from a (x, y, luma), a.k.a. (x, y, Y) tuple.

Source

pub fn with_white_point<NewWp>(self) -> Alpha<Yxy<NewWp, T>, A>

Changes the reference white point without changing the color value.

This function doesn’t change the numerical values, and thus the color it represents in an absolute sense. However, the appearance of the color may not be the same when observed with the new white point. The effect would be similar to taking a photo with an incorrect white balance.

See chromatic_adaptation for operations that can change the white point while preserving the color’s appearance.

Source§

impl<Wp, T, A> Alpha<Yxy<Wp, &T>, &A>

Source

pub fn copied(&self) -> Alpha<Yxy<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Yxy<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, T, A> Alpha<Yxy<Wp, &mut T>, &mut A>

Source

pub fn set(&mut self, value: Alpha<Yxy<Wp, T>, A>)

Update this color with new values.

Source

pub fn as_refs(&self) -> Alpha<Yxy<Wp, &T>, &A>

Borrow this color’s components as shared references.

Source

pub fn copied(&self) -> Alpha<Yxy<Wp, T>, A>
where T: Copy, A: Copy,

Get an owned, copied version of this color.

Source

pub fn cloned(&self) -> Alpha<Yxy<Wp, T>, A>
where T: Clone, A: Clone,

Get an owned, cloned version of this color.

Source§

impl<Wp, Ct, Ca> Alpha<Yxy<Wp, Ct>, Ca>

Source

pub fn get<'a, I, T, A>( &'a self, index: I, ) -> Option<Alpha<Yxy<Wp, &'a <I as SliceIndex<[T]>>::Output>, &'a <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsRef<[T]>, Ca: AsRef<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, with references to the components at index. See slice::get for details.

Source

pub fn get_mut<'a, I, T, A>( &'a mut self, index: I, ) -> Option<Alpha<Yxy<Wp, &'a mut <I as SliceIndex<[T]>>::Output>, &'a mut <I as SliceIndex<[A]>>::Output>>
where T: 'a, A: 'a, Ct: AsMut<[T]>, Ca: AsMut<[A]>, I: SliceIndex<[T]> + SliceIndex<[A]> + Clone,

Get a color, or slice of colors, that allows modifying the components at index. See slice::get_mut for details.

Source§

impl<Wp, T, A> Alpha<Yxy<Wp, Vec<T>>, Vec<A>>

Source

pub fn with_capacity(capacity: usize) -> Alpha<Yxy<Wp, Vec<T>>, Vec<A>>

Create a struct of vectors with a minimum capacity. See Vec::with_capacity for details.

Source

pub fn push(&mut self, value: Alpha<Yxy<Wp, T>, A>)

Push an additional color’s components onto the component vectors. See Vec::push for details.

Source

pub fn pop(&mut self) -> Option<Alpha<Yxy<Wp, T>, A>>

Pop a color’s components from the component vectors. See Vec::pop for details.

Source

pub fn clear(&mut self)

Clear the component vectors. See Vec::clear for details.

Source

pub fn drain<R>( &mut self, range: R, ) -> Iter<Iter<Drain<'_, T>, Wp>, Drain<'_, A>>
where R: RangeBounds<usize> + Clone,

Return an iterator that moves colors out of the specified range.

Trait Implementations§

Source§

impl<C, T> AbsDiffEq for Alpha<C, T>
where C: AbsDiffEq<Epsilon = <T as AbsDiffEq>::Epsilon>, T: AbsDiffEq, <T as AbsDiffEq>::Epsilon: Clone,

Source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> <Alpha<C, T> as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq( &self, other: &Alpha<C, T>, epsilon: <T as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T, C> Add<T> for Alpha<C, T>
where T: Add + Clone, C: Add<T>,

Source§

type Output = Alpha<<C as Add<T>>::Output, <T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, c: T) -> <Alpha<C, T> as Add<T>>::Output

Performs the + operation. Read more
Source§

impl<C, T> Add for Alpha<C, T>
where C: Add, T: Add,

Source§

type Output = Alpha<<C as Add>::Output, <T as Add>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, other: Alpha<C, T>) -> <Alpha<C, T> as Add>::Output

Performs the + operation. Read more
Source§

impl<T, C> AddAssign<T> for Alpha<C, T>
where T: AddAssign + Clone, C: AddAssign<T>,

Source§

fn add_assign(&mut self, c: T)

Performs the += operation. Read more
Source§

impl<C, T> AddAssign for Alpha<C, T>
where C: AddAssign, T: AddAssign,

Source§

fn add_assign(&mut self, other: Alpha<C, T>)

Performs the += operation. Read more
Source§

impl<C> ArrayCast for Alpha<C, <<C as ArrayCast>::Array as ArrayExt>::Item>
where C: ArrayCast, <C as ArrayCast>::Array: NextArray,

Source§

type Array = <<C as ArrayCast>::Array as NextArray>::Next

The output type of a cast to an array.
Source§

impl<C, T, const N: usize> AsMut<[T]> for Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C, T, const N: usize> AsMut<[T; N]> for Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn as_mut(&mut self) -> &mut [T; N]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C, T, const N: usize> AsRef<[T]> for Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, T, const N: usize> AsRef<[T; N]> for Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn as_ref(&self) -> &[T; N]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, T, const N: usize> Blend for Alpha<C, T>
where C: Premultiply<Scalar = T> + StimulusColor + ArrayCast<Array = [T; N]> + Clone, T: Real + Zero + One + MinMax + Clamp + Sqrt + Abs + Arithmetics + PartialCmp + Clone, <T as HasBoolMask>::Mask: LazySelect<T>,

Source§

fn multiply(self, other: Alpha<C, T>) -> Alpha<C, T>

Multiply self with other. This uses the alpha component to regulate the effect, so it’s not just plain component wise multiplication.
Source§

fn screen(self, other: Alpha<C, T>) -> Alpha<C, T>

Make a color which is at least as light as self or other.
Source§

fn overlay(self, other: Alpha<C, T>) -> Alpha<C, T>

Multiply self or other if other is dark, or screen them if other is light. This results in an S curve.
Source§

fn darken(self, other: Alpha<C, T>) -> Alpha<C, T>

Return the darkest parts of self and other.
Source§

fn lighten(self, other: Alpha<C, T>) -> Alpha<C, T>

Return the lightest parts of self and other.
Source§

fn dodge(self, other: Alpha<C, T>) -> Alpha<C, T>

Lighten other to reflect self. Results in other if self is black.
Source§

fn burn(self, other: Alpha<C, T>) -> Alpha<C, T>

Darken other to reflect self. Results in other if self is white.
Source§

fn hard_light(self, other: Alpha<C, T>) -> Alpha<C, T>

Multiply self or other if other is dark, or screen them if self is light. This is similar to overlay, but depends on self instead of other.
Source§

fn soft_light(self, other: Alpha<C, T>) -> Alpha<C, T>

Lighten other if self is light, or darken other as if it’s burned if self is dark. The effect is increased if the components of self is further from 0.5.
Source§

fn difference(self, other: Alpha<C, T>) -> Alpha<C, T>

Return the absolute difference between self and other. It’s basically abs(self - other), but regulated by the alpha component.
Source§

fn exclusion(self, other: Alpha<C, T>) -> Alpha<C, T>

Similar to difference, but appears to result in a lower contrast. other is inverted if self is white, and preserved if self is black.
Source§

impl<C> BlendWith for Alpha<C, <C as Premultiply>::Scalar>
where C: Premultiply,

Source§

type Color = C

The base color type of Self.
Source§

fn blend_with<F>( self, destination: Alpha<C, <C as Premultiply>::Scalar>, blend_function: F, ) -> Alpha<C, <C as Premultiply>::Scalar>
where F: BlendFunction<<Alpha<C, <C as Premultiply>::Scalar> as BlendWith>::Color>,

Blend self, as the source color, with destination, using blend_function. Anything that implements BlendFunction is acceptable, including functions and closures. Read more
Source§

impl<C, T> Clamp for Alpha<C, T>
where C: Clamp, T: Stimulus + Clamp,

Source§

fn clamp(self) -> Alpha<C, T>

Return a new color where out-of-bounds components have been changed to the nearest valid values. Read more
Source§

impl<C, T> ClampAssign for Alpha<C, T>

Source§

fn clamp_assign(&mut self)

Changes out-of-bounds components to the nearest valid values. Read more
Source§

impl<C, T> Clone for Alpha<C, T>
where C: Clone, T: Clone,

Source§

fn clone(&self) -> Alpha<C, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, A> Complementary for Alpha<Cam16UcsJab<T>, A>

Source§

fn complementary(self) -> Alpha<Cam16UcsJab<T>, A>

Return the complementary color of self. Read more
Source§

impl<Wp, T, A> Complementary for Alpha<Lab<Wp, T>, A>
where Lab<Wp, T>: Complementary,

Source§

fn complementary(self) -> Alpha<Lab<Wp, T>, A>

Return the complementary color of self. Read more
Source§

impl<Wp, T, A> Complementary for Alpha<Luv<Wp, T>, A>
where Luv<Wp, T>: Complementary,

Source§

fn complementary(self) -> Alpha<Luv<Wp, T>, A>

Return the complementary color of self. Read more
Source§

impl<T, A> Complementary for Alpha<Oklab<T>, A>
where Oklab<T>: Complementary,

Source§

fn complementary(self) -> Alpha<Oklab<T>, A>

Return the complementary color of self. Read more
Source§

impl<S, T> ComponentOrder<Alpha<Luma<S, T>, T>, [T; 2]> for Al

Source§

fn pack(color: Alpha<Luma<S, T>, T>) -> [T; 2]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 2]) -> Alpha<Luma<S, T>, T>

Split the packed color into its separate components.
Source§

impl<S, T> ComponentOrder<Alpha<Luma<S, T>, T>, [T; 2]> for La

Source§

fn pack(color: Alpha<Luma<S, T>, T>) -> [T; 2]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 2]) -> Alpha<Luma<S, T>, T>

Split the packed color into its separate components.
Source§

impl<S, T> ComponentOrder<Alpha<Rgb<S, T>, T>, [T; 4]> for Abgr

Source§

fn pack(color: Alpha<Rgb<S, T>, T>) -> [T; 4]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 4]) -> Alpha<Rgb<S, T>, T>

Split the packed color into its separate components.
Source§

impl<S, T> ComponentOrder<Alpha<Rgb<S, T>, T>, [T; 4]> for Argb

Source§

fn pack(color: Alpha<Rgb<S, T>, T>) -> [T; 4]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 4]) -> Alpha<Rgb<S, T>, T>

Split the packed color into its separate components.
Source§

impl<S, T> ComponentOrder<Alpha<Rgb<S, T>, T>, [T; 4]> for Bgra

Source§

fn pack(color: Alpha<Rgb<S, T>, T>) -> [T; 4]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 4]) -> Alpha<Rgb<S, T>, T>

Split the packed color into its separate components.
Source§

impl<S, T> ComponentOrder<Alpha<Rgb<S, T>, T>, [T; 4]> for Rgba

Source§

fn pack(color: Alpha<Rgb<S, T>, T>) -> [T; 4]

Combine the components of a color into the packed format.
Source§

fn unpack(packed: [T; 4]) -> Alpha<Rgb<S, T>, T>

Split the packed color into its separate components.
Source§

impl<C> Compose for Alpha<C, <C as Premultiply>::Scalar>

Source§

fn over( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Place self over other. This is the good old common alpha composition equation.
Source§

fn inside( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Results in the parts of self that overlaps the visible parts of other.
Source§

fn outside( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Results in the parts of self that lies outside the visible parts of other.
Source§

fn atop( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Place self over only the visible parts of other.
Source§

fn xor( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Results in either self or other, where they do not overlap.
Source§

fn plus( self, other: Alpha<C, <C as Premultiply>::Scalar>, ) -> Alpha<C, <C as Premultiply>::Scalar>

Add self and other. This uses the alpha component to regulate the effect, so it’s not just plain component wise addition.
Source§

impl<C, T> Debug for Alpha<C, T>
where C: Debug, T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<C, T> Default for Alpha<C, T>
where C: Default, T: Stimulus,

Source§

fn default() -> Alpha<C, T>

Returns the “default value” for a type. Read more
Source§

impl<C, T> DerefMut for Alpha<C, T>

Source§

fn deref_mut(&mut self) -> &mut C

Mutably dereferences the value.
Source§

impl<'de, C, T> Deserialize<'de> for Alpha<C, T>
where C: Deserialize<'de>, T: Deserialize<'de>,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Alpha<C, T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, C> Div<T> for Alpha<C, T>
where T: Div + Clone, C: Div<T>,

Source§

type Output = Alpha<<C as Div<T>>::Output, <T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, c: T) -> <Alpha<C, T> as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<C, T> Div for Alpha<C, T>
where C: Div, T: Div,

Source§

type Output = Alpha<<C as Div>::Output, <T as Div>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, other: Alpha<C, T>) -> <Alpha<C, T> as Div>::Output

Performs the / operation. Read more
Source§

impl<T, C> DivAssign<T> for Alpha<C, T>
where T: DivAssign + Clone, C: DivAssign<T>,

Source§

fn div_assign(&mut self, c: T)

Performs the /= operation. Read more
Source§

impl<C, T> DivAssign for Alpha<C, T>
where C: DivAssign, T: DivAssign,

Source§

fn div_assign(&mut self, other: Alpha<C, T>)

Performs the /= operation. Read more
Source§

impl<Tc, Ta, C, A> Extend<Alpha<Tc, Ta>> for Alpha<C, A>
where C: Extend<Tc>, A: Extend<Ta>,

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = Alpha<Tc, Ta>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a, C, T, const N: usize> From<&'a [T; N]> for &'a Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn from(array: &'a [T; N]) -> &'a Alpha<C, T>

Converts to this type from the input type.
Source§

impl<'a, C, T, const N: usize> From<&'a Alpha<C, T>> for &'a [T]
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn from(color: &'a Alpha<C, T>) -> &'a [T]

Converts to this type from the input type.
Source§

impl<'a, C, T, const N: usize> From<&'a mut [T; N]> for &'a mut Alpha<C, T>
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn from(array: &'a mut [T; N]) -> &'a mut Alpha<C, T>

Converts to this type from the input type.
Source§

impl<'a, C, T, const N: usize> From<&'a mut Alpha<C, T>> for &'a mut [T]
where Alpha<C, T>: ArrayCast<Array = [T; N]>,

Source§

fn from(color: &'a mut Alpha<C, T>) -> &'a mut [T]

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16<T>, T>; N]> for Alpha<Cam16<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16<T>, T>; N]) -> Alpha<Cam16<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Jch<T>, T>; N]> for Alpha<Cam16Jch<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Jch<T>, T>; N]) -> Alpha<Cam16Jch<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Jmh<T>, T>; N]> for Alpha<Cam16Jmh<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Jmh<T>, T>; N]) -> Alpha<Cam16Jmh<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Jsh<T>, T>; N]> for Alpha<Cam16Jsh<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Jsh<T>, T>; N]) -> Alpha<Cam16Jsh<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Qch<T>, T>; N]> for Alpha<Cam16Qch<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Qch<T>, T>; N]) -> Alpha<Cam16Qch<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Qmh<T>, T>; N]> for Alpha<Cam16Qmh<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Qmh<T>, T>; N]) -> Alpha<Cam16Qmh<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16Qsh<T>, T>; N]> for Alpha<Cam16Qsh<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16Qsh<T>, T>; N]) -> Alpha<Cam16Qsh<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16UcsJab<T>, T>; N]> for Alpha<Cam16UcsJab<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16UcsJab<T>, T>; N]) -> Alpha<Cam16UcsJab<V>, V>

Converts to this type from the input type.
Source§

impl<T, V, const N: usize> From<[Alpha<Cam16UcsJmh<T>, T>; N]> for Alpha<Cam16UcsJmh<V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Cam16UcsJmh<T>, T>; N]) -> Alpha<Cam16UcsJmh<V>, V>

Converts to this type from the input type.
Source§

impl<S, T, V, const N: usize> From<[Alpha<Hsl<S, T>, T>; N]> for Alpha<Hsl<S, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Hsl<S, T>, T>; N]) -> Alpha<Hsl<S, V>, V>

Converts to this type from the input type.
Source§

impl<Wp, T, V, const N: usize> From<[Alpha<Hsluv<Wp, T>, T>; N]> for Alpha<Hsluv<Wp, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Hsluv<Wp, T>, T>; N]) -> Alpha<Hsluv<Wp, V>, V>

Converts to this type from the input type.
Source§

impl<S, T, V, const N: usize> From<[Alpha<Hsv<S, T>, T>; N]> for Alpha<Hsv<S, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Hsv<S, T>, T>; N]) -> Alpha<Hsv<S, V>, V>

Converts to this type from the input type.
Source§

impl<S, T, V, const N: usize> From<[Alpha<Hwb<S, T>, T>; N]> for Alpha<Hwb<S, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Hwb<S, T>, T>; N]) -> Alpha<Hwb<S, V>, V>

Converts to this type from the input type.
Source§

impl<Wp, T, V, const N: usize> From<[Alpha<Lab<Wp, T>, T>; N]> for Alpha<Lab<Wp, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Lab<Wp, T>, T>; N]) -> Alpha<Lab<Wp, V>, V>

Converts to this type from the input type.
Source§

impl<Wp, T, V, const N: usize> From<[Alpha<Lch<Wp, T>, T>; N]> for Alpha<Lch<Wp, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,

Source§

fn from(colors: [Alpha<Lch<Wp, T>, T>; N]) -> Alpha<Lch<Wp, V>, V>

Converts to this type from the input type.
Source§

impl<Wp, T, V, const N: usize> From<[Alpha<Lchuv<Wp, T>, T>; N]> for Alpha<Lchuv<Wp, V>, V>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>,