View Source Delux.RGB (delux v0.1.3)

Utilities for RGB tuples

Link to this section Summary

Types

Colors components go from 0 (off) to 1 (brightest)

t()

An RGB triplet

Functions

Create a new RGB tuple

Convert a color to a human-readable ansidata

Link to this section Types

@type color() ::
  :black
  | :red
  | :yellow
  | :green
  | :cyan
  | :blue
  | :magenta
  | :white
  | :on
  | :off
  | t()
@type component() :: 0 | 1 | float()

Colors components go from 0 (off) to 1 (brightest)

@type t() :: {component(), component(), component()}

An RGB triplet

Note that accuracy of the color depends on the LEDs in use. The color should be recognizable, but Delux doesn't support calibration.

Link to this section Functions

@spec new(color()) :: t()

Create a new RGB tuple

You can pass in a tuple or a color name.

Link to this function

to_ansidata(color, prefix \\ "")

View Source
@spec to_ansidata(color(), String.t()) :: IO.ANSI.ansidata()

Convert a color to a human-readable ansidata

iex> RGB.to_ansidata(:red, "This is ")
[:red, "This is ", "red"]
iex> RGB.to_ansidata({0, 0.5, 1}, "This is ")
["This is ", "{0, 0.5, 1}"]