View Source ColorPalette
A library which brings additional named colors via 8 bit ANSI color escape codes
into Elixir (in addition to the 16 standard named IO.ANSI
colors, such as :red
, :blue
, :cyan
,
:light_red
, :light_blue
, :light_cyan
, etc.) ColorPalette
purposely only has minimal dependencies (in
this case, just the Jason
library).
Installation
The package can be installed by adding color_palette
to your list of dependencies in mix.exs
:
def deps do
[
{:color_palette, "~> 0.1"}
]
end
Documentation can be found here and a full list of colors here.
Usage
This hex package adds 396 additional named colors to use in Elixir terminal scripts, based on
the 256 ANSI color code sequences (so some of the color names are duplicates and reference the same color).
Note that some of the colors are approximations, as the color space for the ANSI color codes is rather
limited (it's 8 bit). The values were obtained by accessing TheColorAPI and
also color-name.com.
Usage is similar to IO.ANSI
. So in your Elixir script module, you can either reference ColorPalette
color functions directly (e.g., ColorPalette.aero_blue/0
) or you can import all of the color functions
for easier usage:
def MyModule do
import ColorPalette
def fancy_print do
IO.puts(aero_blue() <> "This line is in aero blue!" <> reset())
IO.puts(alien_armpit() <> "This line is in alien armpit!" <> reset())
end
end
MyModule.fancy_print()
So add some
:alien_armpitto your scripts! Or how about some
:true_blueor
:macaroni_and_cheeseor
:bright_turquoiseor
:dark_candy_apple_redor
:laser_lemonor some
:very_light_malachite_greenSee the main module page for ColorPalette to see a list of all of the colors!
Data Sources
The 256 IO ANSI color codes are readily available, and a copy of them are stored in JSON format
in this data directory..
These colors were manually grouped by the ColorPalette
author into 11 color groups
in this file
(loosely based on the grouping of the web extended colors from here);
note that this was a subjective process.
The 16 IO.ANSI
color names are stored as a module variable here.
Color names were obtained from color-name.com and
thecolorapi.com; Mix.install/2
Elixir scripts to download
this data are found here
and here, respectively.
Color names were also downloaded from colorhexa.com
(via this script),
but the data
was not found to be very interesting, and so these color names were not included.