module ColorUtil
Overview
TODO Write documentation for Colorutil
Extended Modules
Defined in:
colorutil.crcolorutil/baked_palette.cr
colorutil/cmf.cr
colorutil/color.cr
colorutil/semantic_palette.cr
Constant Summary
-
VERSION =
"0.1.0"
Instance Method Summary
-
#approx_relative_luminance(l_hsluv) : Float64
Returns an approximation of the relative luminance of this color.
-
#inverse_approx_relative_luminance(l_wcag) : Float64
Converts a color's approximate relative luminance back into HSLuv luminance.
-
#wcag_contrast(rl_1 : Float64, rl_2 : Float64) : Float64
Returns the WCAG contrast ratio between two colors.
Instance Method Detail
Returns an approximation of the relative luminance of this color. Computing the actual relative luminance requires undergoing a color transformation into rgb before computing - this isn't incredibly computationally expensive (<1ms), but this function returns very similar values with only a few mathematical operators. This transformation only utilizes the l component of an HSLuv color, and is one to one, meaning that it's invertible.
The error is about +/- 0.03 from the exact relative luminance, but this code runs ~200x faster. (See Color#inverse_approx_relative_luminance)
Converts a color's approximate relative luminance back into HSLuv luminance.
Returns the WCAG contrast ratio between two colors.
Parameters: the relative luminosities of both colors.