BigColor

Struct BigColor 

Source
pub struct BigColor { /* private fields */ }
Expand description

BigColor struct represents a color with various formats Using OKLCH as the foundation

Implementations§

Source§

impl BigColor

Source

pub fn new<T: Into<String>>(color: T) -> Self

Create a new BigColor instance from various inputs

Source

pub fn from_string<T: Into<String>>(input: T) -> Result<Self, String>

Alternative constructor for compatibility with old API

Source

pub fn is_dark(&self) -> bool

Returns true if the color is dark

Source

pub fn is_light(&self) -> bool

Returns true if the color is light

Source

pub fn is_valid(&self) -> bool

Returns true if the color is valid

Source

pub fn get_original_input(&self) -> &str

Returns the original input

Source

pub fn get_format(&self) -> ColorFormat

Returns the format of the color

Source

pub fn get_alpha(&self) -> f32

Returns the alpha value

Source

pub fn get_brightness(&self) -> f32

Returns the brightness value

Source

pub fn get_luminance(&self) -> f32

Returns the luminance value

Source

pub fn set_alpha(&mut self, value: f32) -> &mut Self

Sets the alpha value

Source

pub fn to_hsv(&self) -> HSV

Converts the color to HSV

Source

pub fn to_hsv_string(&self) -> String

Converts the color to HSV string

Source

pub fn to_hsl(&self) -> HSL

Converts the color to HSL

Source

pub fn to_hsl_string(&self) -> String

Converts the color to HSL string

Source

pub fn to_oklch(&self) -> OKLCH

Converts the color to OKLCH

Source

pub fn to_oklch_string(&self) -> String

Converts the color to OKLCH string

Source

pub fn to_oklab(&self) -> OKLab

Converts the color to OKLab

Source

pub fn to_oklab_string(&self) -> String

Converts the color to OKLab string

Source

pub fn to_lch(&self) -> LCH

Converts the color to LCH

Source

pub fn to_lch_string(&self) -> String

Converts the color to LCH string

Source

pub fn to_lab(&self) -> Lab

Converts the color to Lab

Source

pub fn to_lab_string(&self) -> String

Converts the color to Lab string

Source

pub fn to_hex(&self, allow_3_char: bool) -> String

Converts the color to HEX

Source

pub fn to_hex_string(&self, allow_3_char: bool) -> String

Converts the color to HEX string

Source

pub fn to_hex8(&self, allow_4_char: bool) -> String

Converts the color to HEX8

Source

pub fn to_hex8_string(&self, allow_4_char: bool) -> String

Converts the color to HEX8 string

Source

pub fn to_rgb(&self) -> RGB

Converts the color to RGB

Source

pub fn to_rgb_string(&self) -> String

Converts the color to RGB string

Source

pub fn to_percentage_rgb(&self) -> PercentageRGB

Converts the color to percentage RGB

Source

pub fn to_percentage_rgb_string(&self) -> String

Converts the color to percentage RGB string

Source

pub fn to_name(&self) -> Option<&'static str>

Converts the color to a name if possible

Source

pub fn to_string(&self, format: Option<ColorFormat>) -> String

Converts the color to a string format

Source

pub fn clone_color(&self) -> Self

Creates a clone of the color

Source

pub fn lighten(&mut self, amount: Option<f32>) -> &mut Self

Lightens the color

Source

pub fn brighten(&mut self, amount: Option<f32>) -> &mut Self

Brightens the color

Source

pub fn darken(&mut self, amount: Option<f32>) -> &mut Self

Darkens the color

Source

pub fn desaturate(&mut self, amount: Option<f32>) -> &mut Self

Desaturates the color

Source

pub fn saturate(&mut self, amount: Option<f32>) -> &mut Self

Saturates the color

Source

pub fn greyscale(&mut self) -> &mut Self

Converts the color to grayscale

Source

pub fn spin(&mut self, amount: f32) -> &mut Self

Spins the hue of the color

Source

pub fn analogous( &self, results: Option<usize>, slices: Option<usize>, ) -> Vec<BigColor>

Creates analogous colors

Source

pub fn complement(&self) -> BigColor

Creates a complement color

Source

pub fn monochromatic(&self, results: Option<usize>) -> Vec<BigColor>

Creates monochromatic colors

Source

pub fn split_complement(&self) -> Vec<BigColor>

Creates split complement colors

Source

pub fn triad(&self) -> Vec<BigColor>

Creates a triad of colors

Source

pub fn tetrad(&self) -> Vec<BigColor>

Creates a tetrad of colors

Source

pub fn polyad(&self, number: usize) -> Vec<BigColor>

Creates polyad colors

Source

pub fn from_rgb(r: u8, g: u8, b: u8, a: f32) -> Self

Creates a BigColor from RGB values

Source

pub fn from_hsl(h: f32, s: f32, l: f32, a: f32) -> Self

Creates a BigColor from HSL values

Source

pub fn from_hsv(h: f32, s: f32, v: f32, a: f32) -> Self

Creates a BigColor from HSV values

Source

pub fn from_lch(l: f32, c: f32, h: f32, a: f32) -> Self

Creates a BigColor from LCH values

Source

pub fn from_oklch(l: f32, c: f32, h: f32, a: f32) -> Self

Creates a BigColor from OKLCH values directly

Source

pub fn from_ratio(color: &str) -> Self

Creates a BigColor from a ratio

Source

pub fn to_hsb(&self) -> HSV

Converts the color to HSB (same as HSV)

Source

pub fn to_hsb_string(&self) -> String

Converts the color to HSB string

Source

pub fn from_hsb(h: f32, s: f32, b: f32, a: f32) -> Self

Creates a BigColor from HSB values (same as HSV)

Source

pub fn to_cmyk(&self) -> CMYK

Converts the color to CMYK

Source

pub fn to_cmyk_string(&self) -> String

Converts the color to CMYK string

Source

pub fn from_cmyk(c: f32, m: f32, y: f32, k: f32, a: f32) -> Self

Create a new BigColor from CMYK values

Source

pub fn to(&self, format: ColorFormat) -> String

Returns the color as a CSS-compatible string in the specified format

Source

pub fn get_contrast_color(&self, intensity: f32) -> BigColor

Gets a contrast color with a specified intensity (0.0 to 1.0)

The intensity parameter controls how strong the contrast will be:

  • 0.0: Minimum contrast (slight difference)
  • 0.5: Medium contrast
  • 1.0: Maximum contrast (black or white)
Source

pub fn get_contrast_ratio(&self, other: &BigColor) -> f32

Gets the contrast ratio between this color and another color according to WCAG standards. The ratio ranges from 1:1 (no contrast) to 21:1 (maximum contrast).

Trait Implementations§

Source§

impl Clone for BigColor

Source§

fn clone(&self) -> BigColor

Returns a duplicate 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 Debug for BigColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BigColor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for BigColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BigColor

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.