This module exports all the main interesting parts of the various
colour modules. It also provides functions for converting between
Colour
and Colour8
.
It is the general intention that "most" work will be done with
Colour
, with values converted to Colour8
only as a final step.
However, full arithmetic on Colour8
is supported anyway,
in case anybody wants to work that way. It is slightly less
efficient and flexible, however.
- data Colour = Colour {}
- grey :: Double -> Colour
- cscale :: Double -> Colour -> Colour
- clip :: Colour -> Colour
- cBlack :: Colour
- cWhite :: Colour
- cRed :: Colour
- cYellow :: Colour
- cGreen :: Colour
- cCyan :: Colour
- cBlue :: Colour
- cMagenta :: Colour
- data Colour8 = Colour8 {}
- grey8 :: Word8 -> Colour8
- c8scale :: Word8 -> Colour8 -> Colour8
- c8Black :: Colour8
- c8White :: Colour8
- c8Red :: Colour8
- c8Yellow :: Colour8
- c8Green :: Colour8
- c8Cyan :: Colour8
- c8Blue :: Colour8
- c8Magenta :: Colour8
- cpromote :: Colour8 -> Colour
- cdemote :: Colour -> Colour8
Documentation
The Colour
type. Stores a red, a green and a blue component as
strict, unboxed Double
values. (So it should be quite efficient
in time and space.) Also provides various class instances for
arithmetic, etc. It is generally assumed that each channel will
have a value somewhere between 0 and 1 at all times.
Note that (*)
acts channel-wise. This is usually what is wanted.
cscale :: Double -> Colour -> ColourSource
Scale a Colour
by a specified amount. (That is, change the
brightness while not affecting the shade.)
clip :: Colour -> ColourSource
Take a Colour
and clip all channels to the range 0--1
inclusive. Any value outside that range will be replaced
with the nearest endpoint (i.e., 0 for negative numbers,
1 for positive numbers higher than 1). Values inside
the range are unaffected.
The Colour
type. Stores a red, a green and a blue component as
strict, unboxed Word8
values. (So it should be quite efficient
in time and space.) Also provides various class instances for
arithmetic, etc.
Note that 0x00 is assumed to mean zero, and 0xFF to mean one.
That means that (*)
is slightly slower than you might expect
due to the extra steps required for renormalisation; (+)
and
(-)
are still efficient, however.
c8scale :: Word8 -> Colour8 -> Colour8Source
Scale a Colour8
by the specified amount. Recall that 0x00
means zero, and 0xFF means one. This means that it is impossible
to make a colour brighter, only darker. It also means this
operation is modestly inefficient due to the renormalisation
steps.
cdemote :: Colour -> Colour8Source
Convert a Colour
into a Colour8
. Any values outside
the range 0--1 will be wrapped
to that range. You may
want to run clip
before calling this function to
prevent this behaviour (unless you know the values can't
be outside the permitted range). This function is the
exact inverse of cpromote
; 0 is mapped to 0x00 and
1 is mapped to 0xFF.