Created Rgb48Color object API (markdown)

Michael Miller
2023-03-29 11:07:40 -07:00
parent 3c4c811d6c
commit 365eca2c3f

90
Rgb48Color-object-API.md Normal file

@@ -0,0 +1,90 @@
Rgb48Color represents a color object that is represented by Red, Green, Blue component values.
## Properties
There are three properties that represent the component values Red, Green, and Blue. The values range from 0 to 65535. Black would 0,0,0 and white would be 65535,65535,65535.
```
uint16_t R;
uint16_t G;
uint16_t B;
```
## Constructors
### Rgb48Color(uint16_t r, uint16_t g, uint16_t b) :
Constructs a Rgb48Color using Red, Green, and Blue color component values.
> * r - value of Red component (0 - 65535)
> * g - value of Green component (0 - 65535)
> * b - value of Blue component (0 - 65535)
### Rgb48Color(uint16_t brightness)
Constructs a Rgb48Color using a single brightness value(0 - 65535). This works well for creating gray tone colors.
> * _brightness_ - brightness value where (0) = black, (32767) = gray, (65535) = white
### Rgb48Color(HtmlColor color);
Construct a Rgb48Color using HtmlColor, converting the Html single value to Rgb component values
> * _color_ - an HtmlColor object
### Rgb48Color(HslColor color);
Construct a Rgb48Color using HslColor, converting the Hsl to Rgb
> * _color_ - an HslColor object
### Rgb48Color(HsbColor color);
Construct a Rgb48Color using HsbColor, converting the Hsb to Rgb
> * _color_ - an HsbColor object
### Rgb48Color()
Construct a Rgb48Color that will have its values set in latter operations.
CAUTION: The R,G,B members are not initialized and may not be consistent until set.
## Methods
### uint16_t CalculateBrightness();
CalculateBrightness will calculate the overall brightness.
NOTE: This is a simple linear brightness
### Rgb48Color Dim(uint16_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-65535) where 65535 will return the original color and 0 will return black.
### Rgb48Color Brighten(uint16_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-65535) where 65535 will return the original color and 0 will return white.
### void Darken(uint16_t delta);
Darken will adjust the color by the given delta toward black.
NOTE: This is a simple linear change.
> * _delta_ - (0-65535) the amount to dim the color by.
### void Lighten(uint16_t delta);
Lighten will adjust the color by the given delta toward white.
NOTE: This is a simple linear change.
> * _delta_ - (0-65535) the amount to lighten the color by.
### static Rgb48Color LinearBlend(Rgb48Color left, Rgb48Color right, float 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.0f - 1.0f) value where 0.0f will return left and 1.0f 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...
```
Rgb48Color results = Rgb48Color::LinearBlend(Rgb48Color(255,0,0), Rgb48Color(0,255,0), 0.33f);
```
### static Rgb48Color LinearBlend(Rgb48Color left, Rgb48Color 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...
```
Rgb48Color results = Rgb48Color::LinearBlend(Rgb48Color(255,0,0), Rgb48Color(0,255,0), 85);
```
### static Rgb48Color BilinearBlend(Rgb48Color c00, Rgb48Color c01, Rgb48Color c10, Rgb48Color c11, float x, float y);
This will blend between four colors by the amount defined by 2d weighting values.
> * _c00_ - upper left quadrant color
> * _c01_ - upper right quadrant color
> * _c10_ - lower left quadrant color
> * _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