Updated RgbwColor object API (markdown)

Michael Miller
2023-03-29 11:37:11 -07:00
parent 9e01253937
commit ca1be3b864

@@ -9,6 +9,18 @@ uint8_t G;
uint8_t B;
uint8_t W;
```
There are also a few constant properties that are helpful to use. These are..
#### Max
The highest value for a single color element.
```
const static uint16_t Max = 255;
```
#### Count
The number of color elements. Useful when accessing the elements using the [] operators.
```
const static size_t Count = 4;
```
## Constructors
### RgbwColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) :
@@ -44,6 +56,16 @@ CAUTION: The R,G,B,W members are not initialized and may not be consistent unti
CalculateBrightness will calculate the overall brightness.
NOTE: For color objects with only W set, it will return W. For color objects with W set to zero this is a simple linear brightness. For color objects with values in W and another color component, the overall brightness is the brighter of the color components and the W.
### RgbwColor Dim(uint8_t ratio);
Dim will return a new color that is blended to black with the given ratio.
NOTE: This is a simple linear change.
> * _ratio_ - (0-255) where 255 will return the original color and 0 will return black.
### RgbwColor Brighten(uint8_t ratio);
Brighten will return a new color that is blended to white with the given ratio.
NOTE: This is a simple linear change.
> * _ratio_ - (0-255) where 255 will return the original color and 0 will return white.
### void Darken(uint8_t delta);
Darken will adjust the color by the given delta toward black.
NOTE: This is a simple linear change.
@@ -63,6 +85,17 @@ This is a static function, which means you need to call it scoped to the object
```
RgbwColor results = RgbwColor::LinearBlend(RgbwColor(255,0,0,0), RgbwColor(0,255,0,10), 0.33f);
```
### static RgbwColor LinearBlend(RgbwColor left, RgbwColor right, uint8_t progress);
This will blend between two colors by the amount defined by the progress variable.
> * _left_ - the color to start the blend at.
> * _right_ - the color to end the blend at.
> * _progress_ - (0 - 255) value where 0 will return left and 255 will return right and a value between will blend the color weighted linearly between them.
This is a static function, which means you need to call it scoped to the object class and not an instance like...
```
RgbwColor results = RgbwColor::LinearBlend(RgbwColor(255,0,0,0), RgbwColor(0,255,0,10), 85);
```
### static RgbwColor BilinearBlend(RgbwColor c00, RgbwColor c01, RgbwColor c10, RgbwColor c11, float x, float y);
This will blend between four colors by the amount defined by 2d weighting values.
> * _c00_ - upper left quadrant color
@@ -71,3 +104,10 @@ This will blend between four colors by the amount defined by 2d weighting values
> * _c11_ - lower right quadrant color
> * _x_ - unit value (0.0 - 1.0) that defines the blend progress in horizontal space
> * _y_ - unit value (0.0 - 1.0) that defines the blend progress in vertical space
## Operators
### uint8_t operator[](size_t idx)
The index operator allows accessing the R, G, B, and W properties using an index. There are both read only and read write versions.
```
uint8_t white = color[3];
```