Color.Scale
- Package
- purescript-colors
- Repository
- sharkdp/purescript-colors
This module defines color scales. A color scale is a continuum of colors
that is defined on the closed interval [0, 1]. It is defined by the two
colors at each endpoint (0 and 1) and possibly additional color stops
in between. If a color scale is sampled between two color stops, the
specified color space is used for linear interpolation (see mix).
#ColorScale Source
data ColorScaleA color scale.
#colorScale Source
colorScale :: ColorSpace -> Color -> List ColorStop -> Color -> ColorScaleCreate a color scale. The color space is used for interpolation between
different stops. The first Color defines the left end (color at ratio
0.0), the list of stops defines possible intermediate steps and the second
Color argument defines the right end point (color at ratio 1.0).
#uniformScale Source
uniformScale :: forall f. Foldable f => ColorSpace -> Color -> f Color -> Color -> ColorScaleCreate a uniform color scale from a list of colors that will be evenly spaced on the scale.
#addStop Source
addStop :: ColorScale -> Color -> Number -> ColorScaleAdd a stop to a color scale.
#sample Source
sample :: ColorScale -> Number -> ColorGet the color at a specific point on the color scale (number between 0 and 1). If the number is smaller than 0, the color at 0 is returned. If the number is larger than 1, the color at 1 is returned.
#colors Source
colors :: ColorScale -> Int -> List ColorA list of colors that is sampled from a color scale. The number of colors can be specified.
#modify Source
modify :: (Number -> Color -> Color) -> ColorScale -> ColorScaleModify the color scale by applying the given function to each color stop. The first argument is the position of the color stop.
#grayscale Source
grayscale :: ColorScaleA scale of colors from black to white.
#spectrum Source
spectrum :: ColorScaleA spectrum of fully saturated hues (HSL color space).
#spectrumLCh Source
spectrumLCh :: ColorScaleA perceptually-uniform spectrum of all hues (LCh color space).
#blueToRed Source
blueToRed :: ColorScaleA perceptually-uniform, diverging color scale from blue to red, similar to the ColorBrewer scale 'RdBu'.
#yellowToRed Source
yellowToRed :: ColorScaleA perceptually-uniform, multi-hue color scale from yellow to red, similar to the ColorBrewer scale YlOrRd.
#hot Source
hot :: ColorScaleA color scale that represents 'hot' colors.
#cool Source
cool :: ColorScaleA color scale that represents 'cool' colors.
#cssColorStops Source
cssColorStops :: ColorScale -> StringA CSS representation of the color scale in the form of a comma-separated
list of color stops. This list can be used in a linear-gradient or
a similar construct.
Note that CSS uses the RGB space for color interpolation. Consequently, if the color scale is in RGB mode, this is just a list of all defined color stops.
For other color spaces, the color scale is sampled at (at least) 10 different points. This should give a reasonable approximation to the true gradient in the specified color space.