Struct random_color::RandomColor
source · pub struct RandomColor {
pub hue: Option<Gamut>,
pub luminosity: Option<Luminosity>,
pub seed: SmallRng,
pub alpha: Option<f32>,
pub color_dictionary: ColorDictionary,
}
Expand description
A structure for generating random colors with a variety of options.
The available options are:
hue
: Specify a specific hue, or a range of hues. You can use theGamut
enum to select a hue.luminosity
: Specify a specific luminosity, or a range of luminosities. You can use theLuminosity
enum to select a luminosity.seed
: Specify a seed for the random number generator. If you don’t specify a seed, one will be generated randomly.alpha
: Specify an alpha value for the generated color. If you don’t specify an alpha value, 1.0 will be used.color_dictionary
: Specify a custom color dictionary. If you don’t specify a color dictionary, the default one will be used.
Fields§
§hue: Option<Gamut>
The hue of the color to generate.
luminosity: Option<Luminosity>
The luminosity of the color to generate.
seed: SmallRng
The seed for the random number generator.
alpha: Option<f32>
The alpha value of the color to generate.
color_dictionary: ColorDictionary
The color dictionary to use.
Implementations§
source§impl RandomColor
impl RandomColor
sourcepub fn hue(&mut self, hue: Gamut) -> &mut RandomColor
pub fn hue(&mut self, hue: Gamut) -> &mut RandomColor
Sets the hue setting.
sourcepub fn luminosity(&mut self, luminosity: Luminosity) -> &mut RandomColor
pub fn luminosity(&mut self, luminosity: Luminosity) -> &mut RandomColor
Removes the luminosity setting.
sourcepub fn seed<T: Seed>(&mut self, seed: T) -> &mut RandomColor
pub fn seed<T: Seed>(&mut self, seed: T) -> &mut RandomColor
Sets the seed.
sourcepub fn alpha(&mut self, alpha: f32) -> &mut RandomColor
pub fn alpha(&mut self, alpha: f32) -> &mut RandomColor
Sets the alpha setting.
sourcepub fn random_alpha(&mut self) -> &mut RandomColor
pub fn random_alpha(&mut self) -> &mut RandomColor
Removes the alpha setting.
sourcepub fn dictionary(&mut self, dictionary: ColorDictionary) -> &mut RandomColor
pub fn dictionary(&mut self, dictionary: ColorDictionary) -> &mut RandomColor
Sets the ColorDictionary.
sourcepub fn to_hsv_array(&mut self) -> [u32; 3]
pub fn to_hsv_array(&mut self) -> [u32; 3]
Generates a random color and returns it as an HSV array.
sourcepub fn to_rgb_string(&mut self) -> String
pub fn to_rgb_string(&mut self) -> String
Generates a random color and returns it as an RGB string.
sourcepub fn to_rgba_string(&mut self) -> String
pub fn to_rgba_string(&mut self) -> String
Generates a random color and returns it as an RGBA string.
sourcepub fn to_rgb_array(&mut self) -> [u8; 3]
pub fn to_rgb_array(&mut self) -> [u8; 3]
Generates a random color and returns it as an RGB array.
sourcepub fn to_rgba_array(&mut self) -> [u8; 4]
pub fn to_rgba_array(&mut self) -> [u8; 4]
Generates a random color and returns it as an RGB array.
sourcepub fn to_f32_rgb_array(&mut self) -> [f32; 3]
pub fn to_f32_rgb_array(&mut self) -> [f32; 3]
Generates a random color and returns it as a f32
RGB array.
sourcepub fn to_f32_rgba_array(&mut self) -> [f32; 4]
pub fn to_f32_rgba_array(&mut self) -> [f32; 4]
Generates a random color and returns it as an f32
RGBA array.
sourcepub fn to_hsl_string(&mut self) -> String
pub fn to_hsl_string(&mut self) -> String
Generates a random color and returns it as an HSL string.
sourcepub fn to_hsla_string(&mut self) -> String
pub fn to_hsla_string(&mut self) -> String
Generates a random color and returns it as an HSLA string.
sourcepub fn to_hsl_array(&mut self) -> [u32; 3]
pub fn to_hsl_array(&mut self) -> [u32; 3]
Generates a random color and returns it as an HSL array.
sourcepub fn into_rgb_array(self) -> [u8; 3]
pub fn into_rgb_array(self) -> [u8; 3]
Transforms the RandomColor
into a u8
array with the color’s RGB values.
sourcepub fn into_rgba_array(self) -> [u8; 4]
pub fn into_rgba_array(self) -> [u8; 4]
Transforms the RandomColor
into a u8
array with the color’s RGBA values.
sourcepub fn into_f32_rgb_array(self) -> [f32; 3]
pub fn into_f32_rgb_array(self) -> [f32; 3]
Transforms the RandomColor
into a f32
array with the color’s RGB values.
sourcepub fn into_f32_rgba_array(self) -> [f32; 4]
pub fn into_f32_rgba_array(self) -> [f32; 4]
Transforms the RandomColor
into a f32
array with the color’s RGBA values.
sourcepub fn to_rgb(&mut self) -> Rgb<u8>
pub fn to_rgb(&mut self) -> Rgb<u8>
Generates a random color and returns it as an Rgb
struct from the rgb
crate.
sourcepub fn to_rgba(&mut self) -> Rgba<u8>
pub fn to_rgba(&mut self) -> Rgba<u8>
Generates a random color and returns it as an Rgba
struct from the rgb
crate.
sourcepub fn to_srgb(&mut self) -> Srgb
pub fn to_srgb(&mut self) -> Srgb
Generates a random color and returns it as an Srgb
struct from the palette
crate.
sourcepub fn to_srgba(&mut self) -> Srgba
pub fn to_srgba(&mut self) -> Srgba
Generates a random color and returns it as an Srgba
struct from the palette
crate.
sourcepub fn to_color32(&mut self) -> Color32
pub fn to_color32(&mut self) -> Color32
Generates a random color and returns it as an Color32
struct from the ecolor
crate.
Trait Implementations§
source§impl Clone for RandomColor
impl Clone for RandomColor
source§fn clone(&self) -> RandomColor
fn clone(&self) -> RandomColor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RandomColor
impl Debug for RandomColor
source§impl Default for RandomColor
impl Default for RandomColor
source§impl From<&mut RandomColor> for Srgba
impl From<&mut RandomColor> for Srgba
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<&mut RandomColor> for Color32
impl From<&mut RandomColor> for Color32
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<&mut RandomColor> for Srgb
impl From<&mut RandomColor> for Srgb
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<&mut RandomColor> for Rgb<u8>
impl From<&mut RandomColor> for Rgb<u8>
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<&mut RandomColor> for Rgba
impl From<&mut RandomColor> for Rgba
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<&mut RandomColor> for Rgba<u8>
impl From<&mut RandomColor> for Rgba<u8>
source§fn from(value: &mut RandomColor) -> Self
fn from(value: &mut RandomColor) -> Self
source§impl From<RandomColor> for Srgba
impl From<RandomColor> for Srgba
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl From<RandomColor> for Color32
impl From<RandomColor> for Color32
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl From<RandomColor> for Srgb
impl From<RandomColor> for Srgb
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl From<RandomColor> for Rgb<u8>
impl From<RandomColor> for Rgb<u8>
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl From<RandomColor> for Rgba
impl From<RandomColor> for Rgba
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl From<RandomColor> for Rgba<u8>
impl From<RandomColor> for Rgba<u8>
source§fn from(value: RandomColor) -> Self
fn from(value: RandomColor) -> Self
source§impl PartialEq for RandomColor
impl PartialEq for RandomColor
impl StructuralPartialEq for RandomColor
Auto Trait Implementations§
impl Freeze for RandomColor
impl RefUnwindSafe for RandomColor
impl Send for RandomColor
impl Sync for RandomColor
impl Unpin for RandomColor
impl UnwindSafe for RandomColor
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more