pub struct BigColor { /* private fields */ }Expand description
BigColor struct represents a color with various formats Using OKLCH as the foundation
Implementations§
Source§impl BigColor
impl BigColor
Sourcepub fn new<T: Into<String>>(color: T) -> Self
pub fn new<T: Into<String>>(color: T) -> Self
Create a new BigColor instance from various inputs
Sourcepub fn from_string<T: Into<String>>(input: T) -> Result<Self, String>
pub fn from_string<T: Into<String>>(input: T) -> Result<Self, String>
Alternative constructor for compatibility with old API
Sourcepub fn get_original_input(&self) -> &str
pub fn get_original_input(&self) -> &str
Returns the original input
Sourcepub fn get_format(&self) -> ColorFormat
pub fn get_format(&self) -> ColorFormat
Returns the format of the color
Sourcepub fn get_brightness(&self) -> f32
pub fn get_brightness(&self) -> f32
Returns the brightness value
Sourcepub fn get_luminance(&self) -> f32
pub fn get_luminance(&self) -> f32
Returns the luminance value
Sourcepub fn to_hsv_string(&self) -> String
pub fn to_hsv_string(&self) -> String
Converts the color to HSV string
Sourcepub fn to_hsl_string(&self) -> String
pub fn to_hsl_string(&self) -> String
Converts the color to HSL string
Sourcepub fn to_oklch_string(&self) -> String
pub fn to_oklch_string(&self) -> String
Converts the color to OKLCH string
Sourcepub fn to_oklab_string(&self) -> String
pub fn to_oklab_string(&self) -> String
Converts the color to OKLab string
Sourcepub fn to_lch_string(&self) -> String
pub fn to_lch_string(&self) -> String
Converts the color to LCH string
Sourcepub fn to_lab_string(&self) -> String
pub fn to_lab_string(&self) -> String
Converts the color to Lab string
Sourcepub fn to_hex_string(&self, allow_3_char: bool) -> String
pub fn to_hex_string(&self, allow_3_char: bool) -> String
Converts the color to HEX string
Sourcepub fn to_hex8_string(&self, allow_4_char: bool) -> String
pub fn to_hex8_string(&self, allow_4_char: bool) -> String
Converts the color to HEX8 string
Sourcepub fn to_rgb_string(&self) -> String
pub fn to_rgb_string(&self) -> String
Converts the color to RGB string
Sourcepub fn to_percentage_rgb(&self) -> PercentageRGB
pub fn to_percentage_rgb(&self) -> PercentageRGB
Converts the color to percentage RGB
Sourcepub fn to_percentage_rgb_string(&self) -> String
pub fn to_percentage_rgb_string(&self) -> String
Converts the color to percentage RGB string
Sourcepub fn to_string(&self, format: Option<ColorFormat>) -> String
pub fn to_string(&self, format: Option<ColorFormat>) -> String
Converts the color to a string format
Sourcepub fn clone_color(&self) -> Self
pub fn clone_color(&self) -> Self
Creates a clone of the color
Sourcepub fn desaturate(&mut self, amount: Option<f32>) -> &mut Self
pub fn desaturate(&mut self, amount: Option<f32>) -> &mut Self
Desaturates the color
Sourcepub fn analogous(
&self,
results: Option<usize>,
slices: Option<usize>,
) -> Vec<BigColor>
pub fn analogous( &self, results: Option<usize>, slices: Option<usize>, ) -> Vec<BigColor>
Creates analogous colors
Sourcepub fn complement(&self) -> BigColor
pub fn complement(&self) -> BigColor
Creates a complement color
Sourcepub fn monochromatic(&self, results: Option<usize>) -> Vec<BigColor>
pub fn monochromatic(&self, results: Option<usize>) -> Vec<BigColor>
Creates monochromatic colors
Sourcepub fn split_complement(&self) -> Vec<BigColor>
pub fn split_complement(&self) -> Vec<BigColor>
Creates split complement colors
Sourcepub fn from_oklch(l: f32, c: f32, h: f32, a: f32) -> Self
pub fn from_oklch(l: f32, c: f32, h: f32, a: f32) -> Self
Creates a BigColor from OKLCH values directly
Sourcepub fn from_ratio(color: &str) -> Self
pub fn from_ratio(color: &str) -> Self
Creates a BigColor from a ratio
Sourcepub fn to_hsb_string(&self) -> String
pub fn to_hsb_string(&self) -> String
Converts the color to HSB string
Sourcepub fn from_hsb(h: f32, s: f32, b: f32, a: f32) -> Self
pub fn from_hsb(h: f32, s: f32, b: f32, a: f32) -> Self
Creates a BigColor from HSB values (same as HSV)
Sourcepub fn to_cmyk_string(&self) -> String
pub fn to_cmyk_string(&self) -> String
Converts the color to CMYK string
Sourcepub fn from_cmyk(c: f32, m: f32, y: f32, k: f32, a: f32) -> Self
pub fn from_cmyk(c: f32, m: f32, y: f32, k: f32, a: f32) -> Self
Create a new BigColor from CMYK values
Sourcepub fn to(&self, format: ColorFormat) -> String
pub fn to(&self, format: ColorFormat) -> String
Returns the color as a CSS-compatible string in the specified format
Sourcepub fn get_contrast_color(&self, intensity: f32) -> BigColor
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)
Sourcepub fn get_contrast_ratio(&self, other: &BigColor) -> f32
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).