wumpus-core-0.23.0: Pure Haskell PostScript and SVG generation.

PortabilityGHC with TypeFamilies and more
Stabilityunstable
Maintainerstephen.tetley@gmail.com

Wumpus.Core.Colour

Contents

Description

RGB, HSB, Gray colour types, and conversions between them.

Internally Wumpus uses RGB3 Double with range [0.0, 1..0] as the colour type. All colour values in the generated SVG or PostScript files will be RGB.

Colour have Num instances for convenience, though the operations of Data.VectorSpace (instances also defined) seem more approriate.

Synopsis

Colour types

type DRGB = RGB3 DoubleSource

RGB representated by Double - values should be in the range 0.0 to 1.0.

  1. 0 represents full saturation, for instance red is 1.0, 0.0, 0.0.

type DHSB = HSB3 DoubleSource

HSB represented by Double - values should be in the range 0.0 to 1.0.

type DGray = Gray DoubleSource

Gray represented by a Double - values should be in the range 0.0 (black) to 1.0 (white).

Utility constructor

iRGB3 :: (Fractional a, Ord a) => Int -> Int -> Int -> RGB3 aSource

iRGB3 : red -> green -> blue -> rgb

Create an RGB colour with intergers in the range [0..255].

255 represents full sturation so red will be 255 0 0 .

Integer values above 255 will be clamped to 255, similarly values below 0 will be clamped to 0.

iHSB3 :: (Fractional a, Ord a) => Int -> Int -> Int -> HSB3 aSource

iGray :: (Fractional a, Ord a) => Int -> Gray aSource

Operations

rgb2hsb :: DRGB -> DHSBSource

Covert RGB [0,1] to HSB [0,1].

hsb2rgb :: DHSB -> DRGBSource

Covert HSB [0,1] to RGB [0,1].

rgb2gray :: DRGB -> DGraySource

Covert RGB [0,1] to Gray [0,1].

gray2rgb :: DGray -> DRGBSource

Covert Gray [0,1] to RGB [0,1].

hsb2gray :: DHSB -> DGraySource

Covert HSB [0,1] to Gray [0,1].

gray2hsb :: DGray -> DHSBSource

Covert Gray [0,1] to HSB [0,1].

Predefined colours

black :: DRGBSource

Black - 0.0, 0.0, 0.0.

white :: DRGBSource

White - 1.0, 1.0, 1.0.

red :: DRGBSource

Red - 1.0, 0.0, 0.0.

green :: DRGBSource

Green - 0.0, 1.0, 0.0.

blue :: DRGBSource

Blue - 0.0, 0.0, 1.0.