newmana/chroma-elm/12.1.0

NOTE: the latest version is 18.2.1

Chroma.Chroma

The attempt here is to provide something similar to https://gka.github.io/chroma.js/ but also idiomatic Elm.

Color

chroma : String -> Result String ExtColor

Given a valid hex string (8, 6 or 3) produce an RGB Color.

name : ExtColor -> Result String String

Given a color turn it into a W3CX11 name or fall back to RGB string.

Types.RGBAColor (Color.rgb255 255 0 255) |> Chroma.name

num : ExtColor -> Int

Numeric representation of RGB.

distance : Mode -> ExtColor -> ExtColor -> Float

Calculate the distance for a given color space.

Calculate the distance in RGB 255 color space.

mix : Mode -> Float -> ExtColor -> ExtColor -> ExtColor

Mix two colors, first converting them to the same color space mode and then with a ratio.

mixChroma : Mode -> Float -> String -> String -> Result String ExtColor

Mix two colors defined as a string, first converting them to the same color space mode and then with a ratio.

average : Mode -> Nonempty ExtColor -> Result String ExtColor

Find the average of a non-empty list of colors, first converting them to the same color space mode.

Only supports RGBA, CYMK and LAB.

averageChroma : Mode -> Nonempty String -> Result String ExtColor

Find the average of a non-empty list of colors defined as strongs, first converting them to the same color space mode.

Only supports RGBA, CYMK and LAB.

limits : LimitMode -> Int -> Nonempty Float -> Nonempty Float

Create breaks/classes based on the data given.

Supports: CkMean (a variant of kMeans), Equal, Logarithmic, and Quantile.

Color Scales

scale : Nonempty ExtColor -> ( Data, Float -> ExtColor )

Return a configuration and a function from a float to color based on default values and a list of colors.

scaleF : (Float -> ExtColor) -> ( Data, Float -> ExtColor )

Return a configuration and a function from a float to color based on default values and a function given a value from 0 -> 1 produces a new color.

colors : Int -> Nonempty ExtColor -> ( Data, Nonempty ExtColor )

Return a configuration and a list of colors based on the number of equal distance buckets to create and a list of colors.

colorsF : Int -> (Float -> ExtColor) -> ( Data, Nonempty ExtColor )

Return a configuration and a list of colors based on the number of equal distance buckets to create and and a function given a value from 0 -> 1 produces a new color.

domain : Nonempty Float -> Nonempty ExtColor -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color based on a new domain and list colors. If using a list of colors, they must be the same length as the domain or only the first and last values will be used.

domainF : Nonempty Float -> (Float -> ExtColor) -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color based on a new domain and a function given a value from 0 -> 1 produces a new color.

classes : Int -> Data -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color using the default configuration, the given colors and the total number of colors (bins) to return.

padding : Float -> Nonempty ExtColor -> ( Data, Float -> ExtColor )

Remove a fraction of the color gradient (0 -> 1). Applies both sides the same.

paddingBoth : ( Float, Float ) -> Nonempty ExtColor -> ( Data, Float -> ExtColor )

Remove a fraction of the color gradient (0 -> 1).

Color Scales Helpers

scaleDefault : ( Data, Float -> ExtColor )

Return a configuration and a function from a float to color based on default values - colors White to Black, domain 0 - 1.

scaleWith : Data -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color based on the given configuration values and the given colors.

colorsWith : Data -> Int -> ( Data, Nonempty ExtColor )

Return the data with the given colors and a new list of colors.

domainWith : Data -> Nonempty Float -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color based on an existing configuration and a new domain. If using a list of colors, they must be the same length as the domain or only the first and last values will be used.

classesWithArray : Nonempty Float -> Data -> ( Data, Float -> ExtColor )

Return a new configuration and a function from a float to color based on the given configuration values, the given colors and a predefined set of breaks/classes.

paddingWith : Data -> Float -> ( Data, Float -> ExtColor )

Remove a fraction of the color gradient (0 -> 1). Applies both sides the same.

paddingBothWith : Data -> ( Float, Float ) -> ( Data, Float -> ExtColor )

Remove a fraction of the color gradient (0 -> 1).