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.)

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 383 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_armpit

to your scripts! Or how about some

:true_blue

or

:macaroni_and_cheese

or

:bright_turquoise

or

:dark_candy_apple_red

or

:laser_lemon

or some

:very_light_malachite_green

See 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.