module

Colorful

Constants

DELTA = 1.0 / 255.0

Constants for color comparisons

Class methods

clamp01(v : Float64) : Float64
Source
fast_happy_color
Source
fast_happy_color_with_rand(rand : Random) : Color

Creates a random bright, "pimpy" color through a restricted HSV space.

Source
fast_warm_color
Source
fast_warm_color_with_rand(rand : Random) : Color

Creates a random dark, "warm" color through a restricted HSV space.

Source
happy_color
Source
happy_color_with_rand(rand : Random) : Color

Creates a random bright, "pimpy" color through restricted HCL space. This is slower than FastHappyColor but will likely give you colors which have the same "brightness" if you run it many times.

Source
hcl_to_lab(h : Float64, c : Float64, l : Float64) : Tuple(Float64, Float64, Float64)
Source
hex(input : String) : Color
Source
hpluv_to_luv_lch(h : Float64, s : Float64, l : Float64) : Tuple(Float64, Float64, Float64)
Source
hsluv_to_luv_lch(h : Float64, s : Float64, l : Float64) : Tuple(Float64, Float64, Float64)
Source
interp_angle(a0 : Float64, a1 : Float64, t : Float64) : Float64

Utility used by Hxx color-spaces for interpolating between two angles in [0,360].

Source
lab_to_hcl(l : Float64, a : Float64, b : Float64) : Tuple(Float64, Float64, Float64)

Helper functions for HCL conversions (polar Lab)

Source
lab_to_xyz_white_ref(l : Float64, a : Float64, b : Float64, wref : Array(Float64)) : Tuple(Float64, Float64, Float64)
Source
linear_rgb_to_xyz(r : Float64, g : Float64, b : Float64) : Tuple(Float64, Float64, Float64)
Source
luv_lch_to_hpluv(l : Float64, c : Float64, h : Float64) : Tuple(Float64, Float64, Float64)
Source
luv_lch_to_hsluv(l : Float64, c : Float64, h : Float64) : Tuple(Float64, Float64, Float64)

Helper functions for HSLuv/HPLuv conversions

Source
luv_lch_to_luv(l : Float64, c : Float64, h : Float64) : Tuple(Float64, Float64, Float64)
Source
luv_to_luv_lch(l : Float64, u : Float64, v : Float64) : Tuple(Float64, Float64, Float64)

Helper functions for LuvLCh conversions (polar Luv)

Source
luv_to_xyz_white_ref(l : Float64, u : Float64, v : Float64, wref : Array(Float64)) : Tuple(Float64, Float64, Float64)
Source
make_color(input : Color) : Color
Source
make_color(col : ColorConvertible) : Tuple(Color, Bool)

Constructs a Color from something implementing ColorConvertible (similar to Go's color.Color). Returns a tuple of {Color, Bool} where the bool indicates success (alpha > 0).

Source
oklab_to_oklch(l : Float64, a : Float64, b : Float64) : Tuple(Float64, Float64, Float64)
Source
oklab_to_xyz(l : Float64, a : Float64, b : Float64) : Tuple(Float64, Float64, Float64)
Source
oklch_to_oklab(l : Float64, c : Float64, h : Float64) : Tuple(Float64, Float64, Float64)
Source
soft_palette(colors_count : Int32) : Array(Color)
Source
soft_palette_ex(colors_count : Int32, settings : SoftPaletteSettings) : Array(Color)
Source
soft_palette_ex_with_rand(colors_count : Int32, settings : SoftPaletteSettings, rand : Random) : Array(Color)

Yeah, windows-stype Foo, FooEx, screw you golang... Uses K-means to cluster the color-space and return the means of the clusters as a new palette of distinctive colors. Falls back to K-medoid if the mean happens to fall outside of the color-space, which can only happen if you specify a CheckColor function.

Source
soft_palette_with_rand(colors_count : Int32, rand : Random) : Array(Color)

A wrapper which uses common parameters.

Source
sorted(cs : Array(Color)) : Array(Color)

Sorted sorts a list of Color values. Sorting is not a well-defined operation for colors so the intention here primarily is to order colors so that the transition from one to the next is fairly smooth.

Source
sq(v : Float64) : Float64

Helper math functions

Source
warm_color
Source
warm_color_with_rand(rand : Random) : Color

Creates a random dark, "warm" color through restricted HCL space. This is slower than FastWarmColor but will likely give you colors which have the same "warmness" if you run it many times.

Source
xyy_to_xyz(x_xy : Float64, y_xy : Float64, yy : Float64) : Tuple(Float64, Float64, Float64)
Source
xyz_to_lab_white_ref(x : Float64, y : Float64, z : Float64, wref : Array(Float64)) : Tuple(Float64, Float64, Float64)
Source
xyz_to_linear_rgb(x : Float64, y : Float64, z : Float64) : Tuple(Float64, Float64, Float64)

Helper functions for RGB/XYZ conversions

Source
xyz_to_luv_white_ref(x : Float64, y : Float64, z : Float64, wref : Array(Float64)) : Tuple(Float64, Float64, Float64)
Source
xyz_to_oklab(x : Float64, y : Float64, z : Float64) : Tuple(Float64, Float64, Float64)

Helper functions for OkLab conversions

Source
xyz_to_uv(x : Float64, y : Float64, z : Float64) : Tuple(Float64, Float64)
Source
xyz_to_xyy(x : Float64, y : Float64, z : Float64) : Tuple(Float64, Float64, Float64)
Source
xyz_to_xyy_white_ref(x : Float64, y : Float64, z : Float64, wref : Array(Float64)) : Tuple(Float64, Float64, Float64)

Helper functions for xyY conversions

Source

Nested types