View Source Colorex.ANSI (Colorex v1.0.0)
Module for generating ANSI escape sequences, similar to IO.ANSI
.
Generate ANSI escape sequences that display truecolor/24-bit color, or with truecolor mode off, it will find the closest 8-bit colors to match.
Summary
Functions
Returns an ANSI escape sequence setting the foreground color.
Returns an ANSI escape sequence setting the background color.
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
Returns an ANSI escape sequence setting the foreground color.
See IO.ANSI
for more information
## Options:
truecolor
- whether to use the full 24-bit color spectrum, or just the standard 256 terminal colors. If you pass truecolor: false
with a color that is not part of the 256 colors, the closest matching color will be chosen. Default: true
fast
- uses the faster color comparison algorithm if true, or the more accurate one if false. See distance/3
for more info. Default: true
iex> IO.puts(Colorex.ansi(Colorex.parse!("#1188FF")) <> "Blue text" <> IO.ANSI.reset())
Returns an ANSI escape sequence setting the background color.
See IO.ANSI
for more information
Options:
truecolor
- whether to use the full 24-bit color spectrum, or just the standard 256 terminal colors. If you pass truecolor: false
with a color that is not part of the 256 colors, the closest matching color will be chosen. Default: true
fast
- uses the faster color comparison algorithm if true, or the more accurate one if false. See distance/3
for more info. Default: true
iex> IO.puts(Colorex.ansi_background(Colorex.parse!("#1188FF")) <> "Blue background" <> IO.ANSI.reset())