pub trait WcagColorContrast<T: WcagRelativeLuminance>: WcagRelativeLuminance + Sized{
// Provided methods
fn wcag_contrast_ratio(&self, other: T) -> f64 { ... }
fn wcag_level(&self, other: T) -> WcagLevel { ... }
fn find_minimum_contrast<Space>(
&self,
other: T,
level: WcagLevel,
) -> Option<Space>
where Self: WcagColorContrast<Space>,
Space: ColorMix<Self, T> + From<Self> + From<T> + Copy + PartialEq + Debug,
Srgb: From<Space>,
Hex: From<Space> { ... }
}
Expand description
Trait for calculating WCAG specified color contrast between colors.
This trait provides methods to determine how perceptually contrasting two colours are using the WCAG relative luminance calculation in Srgb color space.
Provided Methods§
Sourcefn wcag_contrast_ratio(&self, other: T) -> f64
fn wcag_contrast_ratio(&self, other: T) -> f64
Sourcefn wcag_level(&self, other: T) -> WcagLevel
fn wcag_level(&self, other: T) -> WcagLevel
Sourcefn find_minimum_contrast<Space>(
&self,
other: T,
level: WcagLevel,
) -> Option<Space>
fn find_minimum_contrast<Space>( &self, other: T, level: WcagLevel, ) -> Option<Space>
Find the closest color that meets a specific WCAG level against a background.
This function uses ColorMix in the specified Space
to find the minimum adjustment needed to meet the contrast
requirement - mixing the colour at lower percentages to find the lowest percentage mix that would meet the
WcagLevel requirement.
Returns None
if it is impossible to find a
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.