The attempt here is to provide something similar to Chroma.js but also has more features and is idiomatic Elm.
Given a color turn it into a W3CX11 Color name or fall back to an RGB string.
Types.RGBAColor (Color.rgb255 255 0 255) |> Chroma.name
--> Ok "magenta" : Result String StringMix two colors, first converting them to the same color space and then interpolate them with the given ratio.
Chroma.mix Types.RGBA 0.25 (Types.RGBAColor W3CX11.red) (Types.RGBAColor W3CX11.blue)
--> RGBAColor (RgbaSpace 0.75 0 0.25 1) : Types.ExtColorMix two colors defined as a string, first converting them to the same color space mode and then interpolate with the given ratio.
Chroma.mixChroma Types.RGBA 0.25 "red" "blue"
--> Ok (RGBAColor (RgbaSpace 0.75 0 0.25 1)) : Result String Types.ExtColorFind the average of a non-empty list of colors, first converting them to the same color space.
Only supports RGBA, CYMK and LAB.
Chroma.average Types.RGBA (Nonempty.Nonempty (Types.RGBAColor W3CX11.red) [(Types.RGBAColor W3CX11.blue)])
--> Ok (RGBAColor (RgbaSpace 0.5 0 0.5 1)) : Result String Types.ExtColorFind the average of a non-empty list of colors defined as strings, first converting them to the same color space.
Only supports RGBA, CYMK and LAB.
Chroma.averageChroma Types.RGBA (Nonempty.Nonempty "red" ["blue"])
--> Ok (RGBAColor (RgbaSpace 0.5 0 0.5 1)) : Result String Types.ExtColorCombine two colors using the given blend modes.
Chroma.blend Blend.Burn (Types.RGBAColor W3CX11.red) (Types.RGBAColor W3CX11.blue)
--> RGBAColor (RgbaSpace 0 0 1 1) : Types.ExtColorCombine two colors, defined as strings, using the given blend modes.
Chroma.blendChroma Blend.Darken "cyan" "magenta"
--> Ok (RGBAColor (RgbaSpace 0 0 1 1)) : Result String Types.ExtColorWCGA contrast ratio between two colors.
Chroma.contrast (Types.RGBAColor W3CX11.pink) (Types.RGBAColor W3CX11.hotpink)
--> 1.7214765344592284 : FloatWCGA contrast ratio between two colors.
Chroma.contrastChroma "pink" "hotpink"
--> Ok 1.7214765344592284 : Result String FloatCalculate the distance for a given color space.
Chroma.distance Types.RGBA (Types.RGBAColor W3CX11.red) (Types.RGBAColor W3CX11.blue)
--> 1.4142135623730951 : FloatCalculate the distance in RGB 255 color space.
Chroma.distance255 (Types.RGBAColor W3CX11.red) (Types.RGBAColor W3CX11.blue)
--> 360.62445840513925 : FloatCreate breaks/classes based on the data given.
Supports: CkMeans (a variant of kmeans), Equal, Head/Tail, Logarithmic, and Quantile.
Chroma.limits Limits.Equal 5 (Nonempty.Nonempty 0 [ 10 ])
--> Nonempty 0 [2,4,6,8,10] : Nonempty.Nonempty Float
Chroma.limits Limits.CkMeans 3 (Nonempty.Nonempty 1 [ 2, 1, 4, 3, 5, 2, 5, 4 ])
--> Nonempty 1 [2,4] : Nonempty.Nonempty FloatReturn a configuration and a function from a float to a color based on default values and a list of colors.
Return a configuration and a function from a float to a color based on default values and a function given a value from 0 -> 1 produces a new color.
Return a configuration and a list of colors based on the number of equal distance buckets to create and a list of colors.
Return a configuration and a list of colors based on the number of equal distance buckets to create and a function given a value from 0 -> 1 produces a new color.
Return a new configuration and a function from a float to a color based on a new domain and list of colors. The list of colors must be the same length as the domain or only the first and last values will be used.
Return a new configuration and a function from a float to a color based on a new domain and a function given a value from 0 -> 1 produces a new color.
Return a new configuration and a function from a float to a color using the default configuration, the given colors and the total number of colors (bins) to return.
Remove a fraction of the color gradient (0 -> 1). Applies to both sides equally.
Remove a fraction of the color gradient (0 -> 1).
Return a configuration and a function from a float to a color based on the default values - colors White to Black, domain 0 - 1.
Return a new configuration and a function from a float to a color based on the given configuration values and the given colors.
Return the data with the given colors and a new list of colors.
Return a new configuration and a function from a float to a 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.
Return a new configuration and a function from a float to a color based on the given configuration values, the given colors and a predefined set of breaks/classes.
Remove a fraction of the color gradient (0 -> 1). Applies both sides equally.
Remove a fraction of the color gradient (0 -> 1).
Given a valid hex string (8, 6 or 3) or
W3CX11 Colorname and produce an RGB Color.