prizm-0.3.1.1: Compute with colors and differenct color spaces

Stabilitystable
MaintainerParnell Springmeyer <parnell@ixmat.us>
Safe HaskellSafe-Inferred

Data.Prizm.Color

Contents

Description

Color provides functions for blending colors, convenience blending (tint and shade), and adjusting the hue, lightness, or chroma of a given color.

These functions require your color to be represented in CIE L*Ch. The reason for this is because the L*CH color space represents colors closest to how the human eye sees them. Blending and transforming a color in L*Ch maintains the brightness of the colors more accurately. Here is a link to a blog post by someone detailing the differences and documenting them well: Improved Color Blending.

NOTE: the transformations between color spaces are intensive, if you have a HEX or RGB color it first needs to be transformed to the CIEXYZ color space, then the CIELAB space, and finally to CIELCH.

I may at some point try to generalize the function's types but I wanted to first support CIELCH as the transformation format.

Synopsis

Blending

interpolate :: Percent -> (CIELCH Double, CIELCH Double) -> CIELCH DoubleSource

Interpolate two colors with a weight.

Weight is applied left to right, so if a weight of 25% is supplied, then the color on the left will be multiplied by 25% and the second color will be multiplied by 75%.

CIE L*Ch is used because the interpolation between the colors is more accurate than CIELAB, CIEXYZ, and SRGB color spaces.

(<|>) :: CIELCH Double -> CIELCH Double -> CIELCH DoubleSource

Blend two colors using an interpolation value of 50%.

shade :: CIELCH Double -> Percent -> CIELCH DoubleSource

Shade a color by blending it using a weight and the color black.

tint :: CIELCH Double -> Percent -> CIELCH DoubleSource

Tint a color by blending it using a weight and the color white.

Lightness, hue, and chroma

lightness :: CIELCH Double -> Percent -> CIELCH DoubleSource

Adjust the lightness / darkness of a color.

chroma :: CIELCH Double -> Percent -> CIELCH DoubleSource

Adjust the saturation/chroma of a color.

A maximum chroma value of 120 is assumed here, anything more is generally considered out of gamut.

hue :: CIELCH Double -> Percent -> CIELCH DoubleSource

Adjust the hue of a color.

Types