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

Copyright(C) 2013 Parnell Springmeyer
LicenseBSD3
MaintainerParnell Springmeyer <parnell@digitalmentat.com>
Stabilitystable
Safe HaskellSafe
LanguageHaskell2010

Data.Prizm.Color

Contents

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.

class AdjustableColor c where Source #

An adjustable color.

Minimal complete definition

lightness, chroma, hue

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

Preset Colors

class PresetColor c where Source #

Preset white and black for a color space.

Minimal complete definition

white, black

Methods

white :: c Source #

black :: c Source #

Individual Color Spaces

CIE Color Space

RGB Color Space

Package Types (re-exports the individual color space type modules too)