View Source Fledex.Color.Utils (fledex v0.2.0)

Most functions are reimplementations from FastLED. Here is a detailed explanation of those functions: https://github.com/FastLED/FastLED/wiki/High-performance-math

Summary

Functions

This function adds the given subpixels [{r1, g1, b1}, {r2, g2, b2}, ...] together. The result {r1+r2+..., g1+g2+..., b1+b2+...} is probably outside of the standard 8bit range and will have to be rescaled

This function calculates the average of the given "rgb" values

This function combines (adds) the given rgb values and caps them to the given range (by default 0..255)

This function combines the subpixels to a single (color) integer value

This function splits a single (color) integer value into it's rgb components

calculate a fraction mapped to a 8bit range

same as #scale8, except that it does it for all 3 rgb value at the same time.

This function scales a value into a specific range. the video parameter indicates whether the returned value should be correct to not return 0

Splits the rgb-integer value into it's subpixels and returns an {r, g, b} tupel

Functions

@spec add_subpixels([Fledex.Color.Types.rgb()]) ::
  {pos_integer(), pos_integer(), pos_integer()}

This function adds the given subpixels [{r1, g1, b1}, {r2, g2, b2}, ...] together. The result {r1+r2+..., g1+g2+..., b1+b2+...} is probably outside of the standard 8bit range and will have to be rescaled

This function calculates the average of the given "rgb" values

Link to this function

cap(elems, min_max \\ 0..255)

View Source

This function combines (adds) the given rgb values and caps them to the given range (by default 0..255)

@spec combine_subpixels(Fledex.Color.Types.rgb()) :: Fledex.Color.Types.colorint()

This function combines the subpixels to a single (color) integer value

Link to this function

convert_to_subpixels(rgb)

View Source

This function splits a single (color) integer value into it's rgb components

@spec frac8(0..255, 0..255) :: 0..255

calculate a fraction mapped to a 8bit range

Link to this function

nscale8(rgb, scale, video \\ true)

View Source

same as #scale8, except that it does it for all 3 rgb value at the same time.

Link to this function

scale8(value, scale, video \\ false)

View Source
@spec scale8(0..255, 0..255, boolean()) :: 0..255

This function scales a value into a specific range. the video parameter indicates whether the returned value should be correct to not return 0

Link to this function

split_into_subpixels(elem)

View Source
@spec split_into_subpixels(Fledex.Color.Types.colorint()) :: Fledex.Color.Types.rgb()

Splits the rgb-integer value into it's subpixels and returns an {r, g, b} tupel