Portability | GHC with TypeFamilies and more |
---|---|
Stability | unstable |
Maintainer | stephen.tetley@gmail.com |
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.
- data RGB3 a = RGB3 !a !a !a
- type DRGB = RGB3 Double
- data HSB3 a = HSB3 !a !a !a
- type DHSB = HSB3 Double
- newtype Gray a = Gray a
- type DGray = Gray Double
- iRGB3 :: (Fractional a, Ord a) => Int -> Int -> Int -> RGB3 a
- iHSB3 :: (Fractional a, Ord a) => Int -> Int -> Int -> HSB3 a
- iGray :: (Fractional a, Ord a) => Int -> Gray a
- rgb2hsb :: DRGB -> DHSB
- hsb2rgb :: DHSB -> DRGB
- rgb2gray :: DRGB -> DGray
- gray2rgb :: DGray -> DRGB
- hsb2gray :: DHSB -> DGray
- gray2hsb :: DGray -> DHSB
- black :: DRGB
- white :: DRGB
- red :: DRGB
- green :: DRGB
- blue :: DRGB
Colour types
Red-Green-Blue - no alpha.
RGB3 !a !a !a |
Eq a => Eq (RGB3 a) | |
Fractional a => Fractional (RGB3 a) | |
Num a => Num (RGB3 a) | |
Show a => Show (RGB3 a) | |
Num a => VectorSpace (RGB3 a) | |
Num a => AdditiveGroup (RGB3 a) | |
PSColour (RGB3 Double) | |
Ellipse (RGB3 Double) | |
TextLabel (RGB3 Double) | |
Fill (RGB3 Double) | |
Stroke (RGB3 Double) | |
Ellipse (RGB3 Double, [StrokeAttr]) | |
Ellipse (RGB3 Double, StrokeAttr) | |
Ellipse (RGB3 Double, DrawEllipse) | |
TextLabel (RGB3 Double, FontAttr) | |
Stroke (RGB3 Double, [StrokeAttr]) | |
Stroke (RGB3 Double, StrokeAttr) |
RGB representated by Double - values should be in the range 0.0 to 1.0.
- 0 represents full saturation, for instance red is 1.0, 0.0, 0.0.
Hue-Saturation-Brightness.
HSB3 !a !a !a |
Eq a => Eq (HSB3 a) | |
Fractional a => Fractional (HSB3 a) | |
Num a => Num (HSB3 a) | |
Show a => Show (HSB3 a) | |
Num a => VectorSpace (HSB3 a) | |
Num a => AdditiveGroup (HSB3 a) | |
PSColour (HSB3 Double) | |
Ellipse (HSB3 Double) | |
TextLabel (HSB3 Double) | |
Fill (HSB3 Double) | |
Stroke (HSB3 Double) | |
Ellipse (HSB3 Double, [StrokeAttr]) | |
Ellipse (HSB3 Double, StrokeAttr) | |
Ellipse (HSB3 Double, DrawEllipse) | |
TextLabel (HSB3 Double, FontAttr) | |
Stroke (HSB3 Double, [StrokeAttr]) | |
Stroke (HSB3 Double, StrokeAttr) |
Gray scale.
Gray a |
Eq a => Eq (Gray a) | |
Fractional a => Fractional (Gray a) | |
Num a => Num (Gray a) | |
Ord a => Ord (Gray a) | |
Show a => Show (Gray a) | |
Num a => VectorSpace (Gray a) | |
Num a => AdditiveGroup (Gray a) | |
PSColour (Gray Double) | |
Ellipse (Gray Double) | |
TextLabel (Gray Double) | |
Fill (Gray Double) | |
Stroke (Gray Double) | |
Ellipse (Gray Double, [StrokeAttr]) | |
Ellipse (Gray Double, StrokeAttr) | |
Ellipse (Gray Double, DrawEllipse) | |
TextLabel (Gray Double, FontAttr) | |
Stroke (Gray Double, [StrokeAttr]) | |
Stroke (Gray Double, StrokeAttr) |
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.