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
@spec avg([Fledex.Color.Types.rgb()]) :: Fledex.Color.Types.rgb()
This function calculates the average of the given "rgb" values
@spec cap([Fledex.Color.Types.rgb()], Range.t()) :: Fledex.Color.Types.rgb()
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
@spec convert_to_subpixels( Fledex.Color.Types.colorint() | atom() | Fledex.Color.Types.rgb() | %{rgb: Fledex.Color.Types.rgb()} | %{rgb: Fledex.Color.Types.colorint()} ) :: Fledex.Color.Types.rgb()
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
@spec nscale8(Fledex.Color.Types.rgb(), 0..255, boolean()) :: Fledex.Color.Types.rgb()
@spec nscale8(Fledex.Color.Types.rgb(), Fledex.Color.Types.rgb(), boolean()) :: Fledex.Color.Types.rgb()
@spec nscale8(Fledex.Color.Types.colorint(), Fledex.Color.Types.rgb(), boolean()) :: Fledex.Color.Types.colorint()
same as #scale8, except that it does it for all 3 rgb value at the same time.
@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
@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