3b Fledex: Everything about Colors
Mix.install([
{:fledex, "~>0.5"}
])
Colors and different drivers
Different drivers have different color characteristics. Therefore you might have to adjust the colors when migrating from one output to another. Some drivers allow some color correction to try to adjust for those issues (see also the ‘Color Correction’ section.
Color Information
Fledex has an extensive set of predefined colors from Wikipedia. You can retrieve those names by calling
Fledex.Color.Names.names()
You can also retrieve the complete data set by calling
Fledex.Color.Names.colors()
Here a list of all the colors:
Kino.DataTable.new(Fledex.Color.Names.colors(),
keys: [:descriptive_name, :name, :rgb, :hex, :hsv, :hsl, :source],
sorting_enabled: true
)
You can also retrieve the information from a specific color, like :almond
in the following way
-
almond/0
: Every color has it’s own function and the :hex value (represented as integer) will be returned -
almond/1
: This allows the retrieve a specific representation. It should be noted, that the color functions (that are oftne just approximations), do not provide the same results. The values returned here are the ones as defined on the Wikipedia page:-
:all
: This retrieves the full data set -
:hex
: This is the same asalmond/0
-
:rgb
: This retrieves an RGB struct, i.e.{r, g, b}
-
:hsv
: This retrieves an HSV struct, i.e.{h, s, v}
-
:hsl
: This retrieves an HSL struct, i.e.{h, s, l}
-
:index
: The index of this color in the list of all colors -
:desriptive_name
: a string with name (from this the Atom is derived) -
:source
: Information where the color comes from, see Wikipedia for more details
-
-
info/1
andinfo/2
: They are convenience functions when you only have an atom as the color name. They map to the functions, thusinfo(:almond)
is equal toalmond()
andinfo(:almond, what)
is equal toalmond(what)
.
In addition each color can also be used directly in an Leds
sequence since it provides to convenience functions:
-
almond(leds)
which takes anLeds
sequence and adds the:almond
color to it (at the next position). This is equivalent to:leds |> Leds.light(almond(:hex))
-
almond(leds, offset)
which takes anLeds
sequence and an offset to specify where the led should be positioned. This is equivalent to:leds |> Leds.light(almond(:hex), offset)
This allows for a very natural way to define an led sequence. especially if we import the Fledex.Leds
and Fledex.Color.Names
modules.
import Fledex.Leds
import Fledex.Color.Names
leds(5) |> almond |> red |> green |> blue(5)
Color Correction
More info to follow