AC-Colour-1.1.6: Efficient RGB colour types.

Safe HaskellSafe-Inferred




This module provides 1-dimensional colour maps with smooth (linear) colour blending between control points.



range_cycle :: (Double, Double) -> Double -> DoubleSource

Takes a range and a value, and returns a value inside the given range. If the value is already in the range, it is unchanged. Otherwise it "wraps around". For example, if the range is (0, 1) then, in effect, the fractional part of the value is returned.

Note that extremely narrow ranges may exhibit numerical instability.

Simple colour range

type ColourMap = [(Double, Colour)]Source

This is the basic colour map type. It consists of a list of control points, each one being a parameter value and the colour at that parameter value. The colour at other parameter values is linearly interpolated between the control points.

Parameter values outside the range (i.e., below the first point or above the last point) take the colour of the end control point. This means that in the degenerate case of a single control point, the colour is applied everywhere (and the parameter value is ignored).

A map with zero control points is not permitted.

colour_map :: ColourMap -> Double -> ColourSource

Compute the value of a colour map at a particular parameter value.

Repeating colour range

data FullColourMap Source

This is a colour map with has optional repeating behaviour using range_cycle above.

Notice that the parameter range that gets repeated need not cover the entire range of the underlying ColourMap.


SimpleMap ColourMap

Colour map which does not repeat.

RepeatingMap (Double, Double) ColourMap

Colour map which repeats.

full_colour_map :: FullColourMap -> Double -> ColourSource

Compute the value of a full colour map at a particular parameter value, similar to colour_map.