Color parsing and SGR code generation.
Accepted color inputs:
- Hex strings:
"#FF8800"or"#f80" - RGB tuples:
{255, 136, 0} - Named atoms:
:black,:red,:green,:yellow,:blue,:magenta,:cyan,:whiteand their:bright_*variants nilfor the terminal default
Summary
Functions
Returns the SGR codes (a list of integers) for a color in the given layer
(:fg or :bg). Returns [] for nil.
Types
Functions
@spec to_sgr(t(), :fg | :bg) :: [non_neg_integer()]
Returns the SGR codes (a list of integers) for a color in the given layer
(:fg or :bg). Returns [] for nil.
Examples
iex> Tuix.Color.to_sgr("#FF8800", :fg)
[38, 2, 255, 136, 0]
iex> Tuix.Color.to_sgr(:red, :bg)
[41]
iex> Tuix.Color.to_sgr(nil, :fg)
[]