Color.Scale
- Package
- purescript-colors
- Repository
- purescript-contrib/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 is represented by a list of ColorStops and a ColorSpace that is
used for interpolation between the stops.
#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).
#ColorStops Source
data ColorStopsRepresents all ColorStops in a color scale. 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).
Constructors
#combineStops' Source
combineStops' :: Number -> Number -> ColorStops -> ColorStops -> ColorStopsLike combineStops, but the width of the "transition zone" can be specified as the
first argument.
Example:
redToBlue `combineStops epsilon x` orangeToGray
Here, the color at x will be orange and color at x - epsilon will be blue.
If we want the color at x to be blue, combineStops' epsilon (x + epsilon) could be used.
#combineStops Source
combineStops :: Number -> ColorStops -> ColorStops -> ColorStopsConcatenates two color scales. The first argument specifies the transition point as a number between zero and one. The color right at the transition point is the first color of the second color scale.
Example:
redToBlue `combineStops 0.4` orangeToGray
#reverseStops Source
reverseStops :: ColorStops -> ColorStopsTakes ColorStops and returns reverses it
#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.
#uniformScale' Source
uniformScale' :: forall f. Foldable f => Color -> f Color -> Color -> ColorStopsCreate ColorStops from a list of colors such that they will be evenly
spaced on the scale.
#addStop Source
addStop :: ColorScale -> Color -> Number -> ColorScaleAdd a stop to a color scale.
#addStop' Source
addStop' :: ColorStops -> Color -> Number -> ColorStopsAdd a stop to a list of ColorStops.
#sample Source
sample :: ColorScale -> Number -> ColorGet the color at a specific point on the color scale by linearly
interpolating between its colors (see mix and mkSimpleSampler).
#cubehelixSample Source
cubehelixSample :: ColorStops -> Number -> ColorGet the color at a specific point on the color scale, using the cubehelix
interpolation (see mixCubehelix and mkSimpleSampler).
#mkSimpleSampler Source
mkSimpleSampler :: Interpolator -> ColorStops -> 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.
#modify' Source
modify' :: (Number -> Color -> Color) -> ColorStops -> ColorStopsModify a list of ColorStops 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.
#hot Source
hot :: ColorScaleA color scale that represents 'hot' colors.
#cool Source
cool :: ColorScaleA color scale that represents 'cool' colors.
#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.
#cubehelix Source
cubehelix :: ColorScaleThe standard cubehelix color scale.
#minColorStops Source
minColorStops :: Int -> (ColorStops -> Number -> Color) -> ColorStops -> ColorStopsTakes number of stops ColorStops should contain, function to generate
missing colors and ColorStops itself.
#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.
#cssColorStopsRGB Source
cssColorStopsRGB :: ColorStops -> StringUnderling function of cssColorStops.
- Modules
- Color
- Color.
Blending - Color.
Scale