View Source Colorex.Utils (Colorex v1.0.0)
Some handy functions for working with colors
Summary
Functions
Convienience function to get the color black
Print a visual of two colors being mixed.
Print a row of color swatches.
Generates a random color.
Convienience function to get the color white
Types
@type color() :: Colorex.Color.t() | colorspace_color()
@type color_key() ::
:red
| :green
| :blue
| :alpha
| :hue
| :saturation
| :lightness
| :l
| :a
| :b
| :cyan
| :magenta
| :yellow
| :black
| :x
| :y
| :z
@type colorspace_color() :: Colorex.RGB.t() | Colorex.HSL.t() | Colorex.LAB.t() | Colorex.XYZ.t() | Colorex.CMYK.t()
@type float_0_to_1() :: float()
@type integer_0_to_255() :: pos_integer()
@type rgba_tuple() :: {integer_0_to_255(), integer_0_to_255(), integer_0_to_255(), float_0_to_1()}
Functions
@spec black() :: Colorex.Color.t()
Convienience function to get the color black
@spec print_color_mix( color :: color(), color2 :: color(), color3 :: color(), size :: pos_integer() ) :: :ok
Print a visual of two colors being mixed.
Prints two overlapping squares that look like colors being mixed.
Arg 1 is the top right square. Arg 2 is the bottom left square. Arg 3 is the middle overlapping square. Arg 4 is an optional size parameter.
┌──────────┐ │ Arg 1 │ ┌───│──────┐ │ │ │ Arg3 │ │ │ └──────────┘ │ Arg 2 │ └──────────┘
Requires a terminal that supports truecolor.
@spec print_swatches([color()], pos_integer()) :: :ok
Print a row of color swatches.
Will print a colored square for each color in the list, all in a row.
The size
argument is the size of each square.
Useful for debugging or seeing colors in the terminal. Requires a terminal that supports truecolor.
Generates a random color.
@spec white() :: Colorex.Color.t()
Convienience function to get the color white