Structured representation of a color in all supported formats.
Pote.ColorInfo holds a color's values across multiple color spaces
(RGB, HEX, HSL, HSV, CMYK, XTerm256, ARGB) and provides convenient
methods for harmonies, lightness adjustments, and ANSI output.
Create a ColorInfo from any valid color input using new/1.
Examples
iex> ci = Pote.ColorInfo.new("#FF8000")
iex> ci.rgb
{255, 128, 0}
iex> ci.hex
"#FF8000"
Summary
Functions
Returns two analogous colors (offset by angle degrees).
Returns the map of basic ANSI colors.
Returns the complementary color (180 opposite on the wheel).
Returns a darker variant of the color blended with black.
Returns a lighter variant of the color blended with white.
Finds the nearest basic ANSI color name for a given RGB value.
Creates a new empty ColorInfo structure.
Creates a new ColorInfo from various inputs.
Converts ColorInfo to ANSI escape code.
Returns the triad harmony (base + 120 + 240).
Types
@type argb() :: {0..255, 0..255, 0..255, 0..255}
@type rgb() :: {0..255, 0..255, 0..255}
Functions
Returns two analogous colors (offset by angle degrees).
@spec basic_colors() :: %{required(atom()) => {0..255, 0..255, 0..255}}
Returns the map of basic ANSI colors.
Returns the complementary color (180 opposite on the wheel).
Returns a darker variant of the color blended with black.
Returns a lighter variant of the color blended with white.
Finds the nearest basic ANSI color name for a given RGB value.
Examples
iex> Pote.ColorInfo.nearest_basic_color({255, 0, 0})
:red
iex> Pote.ColorInfo.nearest_basic_color({250, 10, 5})
:red
@spec new() :: t()
Creates a new empty ColorInfo structure.
Creates a new ColorInfo from various inputs.
Converts ColorInfo to ANSI escape code.
Returns the triad harmony (base + 120 + 240).