Go to the first, previous, next, last section, table of contents.

The Colourmap interface


data Colourmap {- abstract -}
 
  {- allocate new colour (read-only or r/w) -}
newColour :: Colourmap -> Bool -> Colour -> IO Pixel
 {- try to allocate new colour, try alloc fallback if not possible. -}
newColourFallback :: Colourmap -> Bool -> Colour   -> Colour -> IO Pixel
 {- allocate new colour by transforming a colour -}
transformColour :: Colourmap -> Bool -> (RGB -> RGB) -> Colour -> IO (Pixel, RGB)
 {- same as above, but revert to fallback colour if not poss. -}
transformColourFallback :: Colourmap -> Bool -> (RGB -> RGB) -> Colour -> Colour -> IO (Pixel, RGB)

 {- assoc. new colour with pixel value (overwrite colour) -}
changePixel :: Colourmap -> Pixel -> Colour -> IO RGB

 {- default fg&bg -}
defaultForeground :: Colourmap -> IO Pixel
defaultBackground :: Colourmap -> IO Pixel
 {- free colour assoc. with pixel value from colourmap -}
deleteColour :: Colourmap -> Pixel -> IO ()

 {- get info on pixel value -}
queryPixel :: Colourmap -> Pixel -> IO (Colour, RGB)
isReadOnly :: Colourmap -> Pixel -> IO Bool

 {- size of colour map -}
noOfColourmapCells, -- :: Colourmap -> Int

* newColour cmap readOnly colour
allocate an entry in the Colourmap for the colour value. The readOnly flag controls whether the entry should be writeable or not. The operation will fail if the colour cannot be allocated.

* newColourFallback cmap readOnly colour fback_colour
same as newColour, but if, for some reason, the colour value cannot be allocated, try using the fallback colour. If both fail, the operation fail.

* transformColour cmap readOnly f colour
allocate a new colour using the RGB value of the colour value to compute the new colour we want to allocate. The readOnly control whether entry should be writeable or not. Useful for implementing stuff like brighten/darken, although see Colour for an alternative and more declarative way of transforming colour values.

* changePixel cmap pixel colour
If the colourmap entry matched by the pixel value is writeable, change the entry to use colour instead.

* queryPixel cmap pixel
return the Colour value and RGB triple associated with the pixel value in the colourmap. Fails if the pixel is not present in the colourmap.

* isReadOnly cmap pixel
return the read-only/writeable flag for a pixel value.

Go to the first, previous, next, last section, table of contents.