prizm-3.0.0: Convert colors to different color spaces, interpolate colors, and transform colors

Data.Prizm.Color

Description

Data.Prizm.Color exports all of the specific color space modules and types for blending colors, convenience blending (tint and shade), and adjusting the hue, lightness, or chroma of a given color. You should import this module.

Note that blending colors in a polar-coordinate color space, such as CIELCH, preserves the saturation and brightness of the colors being interpolated better than blending in RGB. It also turns out to be an effective even when converting from RGB to CIELCH, blending, then converting back again!

Here is an excellent blog post by someone discussing the differences: Improved Color Blending.

Synopsis

# Color Transformations

class BlendableColor c where Source #

A blendable color.

Minimal complete definition

interpolate

Methods

interpolate :: Percent -> (c, c) -> c Source #

Linear interpolation of a color with another color, applying a weight.

(<~>) :: c -> c -> c Source #

Blend two BlendableColor colors using an interpolation weight of 50%.

shade :: PresetColor c => c -> Percent -> c Source #

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

tint :: PresetColor c => c -> Percent -> c Source #

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

Instances

 Source # Methodsinterpolate :: Percent -> (LCH, LCH) -> LCH Source #(<~>) :: LCH -> LCH -> LCH Source #tint :: LCH -> Percent -> LCH Source #

class AdjustableColor c where Source #

Minimal complete definition

Methods

lightness :: c -> Percent -> c Source #

Adjust the lightness of a color

chroma :: c -> Percent -> c Source #

Adjust the chroma of a color

NB: not all color spaces will support this easily but it should be possible to convert into a color space that does then convert back

hue :: c -> Percent -> c Source #

Adjust the hue of a color

Instances

 Source # Methodshue :: LCH -> Percent -> LCH Source #

# Preset Colors

class PresetColor c where Source #

Preset white and black for a color space.

Minimal complete definition

Methods

white :: c Source #

black :: c Source #

Instances

 Source # Methods Source # Methods