Powered by AppSignal & Oban Pro

3b Fledex: Everything about Colors

3b_fledex_everything_about_colors.livemd

3b Fledex: Everything about Colors

Mix.install([
  {:fledex, "~>0.6"}
])

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, CSS, SVG, and RAL.Apart from the last list (which is not so commonly used), they are all combined together to a single Names module. 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 (except the RAL colors, those can be found in Fledex.Color.Names.RAL):

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 often just approximations), do not provide the same results. The values returned here are the ones as defined in their sources:
    • :all: This retrieves the full data set
    • :hex: This is the same as almond/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 (we derive the Atom from it)
    • :source: Information where the color comes from. Even the colors on Wikipedia are often coming from other sources.
  • info/1 and info/2: They are convenience functions when you only have an atom as the color name. They map to the functions, thus info(:almond) is equal to almond() and info(:almond, what) is equal to almond(what).

In addition each color can also be used directly in an Leds sequence since it provides two convenience functions:

  • almond(leds) which takes an Leds sequence and adds the :almond color to it (at the next position). This is equivalent to:
    leds |> Leds.light(almond(:hex))
  • almond(leds, opts) which takes an Leds sequence and an some other options, like the offset to specify where the led should be positioned. This is equivalent to:
    leds |> Leds.light(almond(:hex), offset: 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(offset: 5)

Color Correction

Before we look at the Fledex features regarding color correction we first need to understand what color correction is. Wikipedia describes the process nicely as:

> Color correction is a technical process that fixes color issues and makes footage appear as > naturalistic as possible. The idea is for colors to look clean and real, as human eyes would see > them in the real world – basically, correcting problems of the underlying image by balancing out > the colors, making the whites appear white, the blacks appear black, and making sure that > everything is even.

The color correction consists of two parts. First to compensate the physical mis-coloring of the LEDs. The basic colors on the classical 5050 LED chip are not shown in the same intensity. So we need to compensate this.

The second color coorection we might want to perform is to bring the color into the correct “temperature” (named due to the black body radiator) with a relatively continuous spectrum, or approach the light of a gaseous light source with more discrete spectral band (see gas discharge lamp).

Color correction is provided in Fledex through the modules under Fledex.Color.Correction.

> Note > > If you look at color conversion (hsv2rgb) there is also the possibility to color correct, > but you probably don’t want to touch that.