The prizm package

[Tags:bsd3, library, test]

prizm is a Haskell library for transforming colors. Specifically, providing functions for transforming between different color spaces (CIE and sRGB), interpolating colors and adjusting the tint, shade, hue, or lightness of a color.

The inspiration for this library came from a desire to blend two colors represented in the sRGB color space. My research about color blending and color space representation in the computer led me to the conclusion that the CIE L*Ch color space is the most effective for blending because it most accurately represents how the human eye sees hue and therefore preserves (and blends) hue the most accurately.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.3.1.0, 0.3.1.1, 0.3.1.2, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 2.0.0, 2.0.1 (info)
Dependencies base (>=4.5 && <5), convertible (>=1.1), mono-traversable (>=1.0), text (>=0.11.2.3) [details]
License BSD3
Copyright (c) 2013 Parnell Springmeyer
Author Parnell Springmeyer
Maintainer parnell+hackage@digitalmentat.com
Category Graphics
Home page https://github.com/ixmatus/prizm
Bug tracker https://github.com/ixmatus/prizm/issues
Source repository head: git clone https://github.com/ixmatus/prizm
Uploaded Fri Mar 17 14:37:56 UTC 2017 by ParnellSpringmeyer
Distributions NixOS:2.0.1
Downloads 2264 total (22 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2017-03-17 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for prizm

Readme for prizm-2.0.1

Welcome!

Hackage Version Travis CI Status

prizm is a Haskell library for transforming colors. Specifically, providing functions for transforming between different color spaces (CIE and sRGB), interpolating colors and adjusting the tint, shade, hue, or lightness of a color.

The inspiration for this library came from a desire to blend two colors represented in the sRGB color space. My research about color blending and color space representation in the computer led me to the conclusion that the CIE L*Ch color space is the most effective for blending because it most accurately represents how the human eye sees hue and therefore preserves (and blends) hue the most accurately.

Quickstart

{-# LANGUAGE ScopedTypeVariables #-}

import Data.Convertible
import Data.Prizm.Color
import Data.Prizm.Color.CIE as CIE

main = do
  -- Convert RGB colors to the CIE.LCH color space
  let green :: CIE.LCH = convert $ RGB 102 255 0
      pink  :: CIE.LCH = convert $ RGB 255 0 255

      -- Blend with a weight of 50%
      blended50 = pink <~> green

      -- Blend with a weight of 20%
      blended20 = interpolate 20 (pink,green)

  -- Print the CIE.LCH representation
  putStrLn $ show blended50

  -- Print the RGB representation of the blended color
  putStrLn . show $ (convert blended20) :: RGB

  -- Print the CSS-friendly hexadecimal RGB representation of the blended color
  putStrLn . show $ (convert blended20) :: Hex
      

Supported Algorithms

  • sRGB <-> CIE XYZ
  • CIE XYZ <-> CIE L*ab
  • CIE L*ab <-> CIE L*Ch

Supported Functions

  • Color interpolation
  • Tinting / Darkening
  • Lightness
  • Hue
  • Chroma/Saturation

Examples

Example blending with CIELCH converted back to RGB.

References