diff --git a/RgbwColor-object-API.md b/RgbwColor-object-API.md new file mode 100644 index 0000000..cae71bf --- /dev/null +++ b/RgbwColor-object-API.md @@ -0,0 +1,59 @@ +RgbwColor represents a color object that is represented by Red, Green, Blue, and White component values. Its primary use is to contain and manipulate colors for 4 element Pixels. + +## Properties +There are three properties that represent the component values Red, Green, Blue, and White. The values range from 0 to 255. Black would 0,0,0,0 and white using the color leds would be 255,255,255,0 and white using the white led would be 0,0,0,255. + +``` +uint8_t R; +uint8_t G; +uint8_t B; +uint8_t W; +``` +## Constructors + +### RgbwColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) : +Constructs a RgbwColor using Red, Green, Blue, and White component values. + +### RgbwColor(uint8_t brightness) +Constructs a RgbwColor using a single brightness value(0 - 255). This works well for creating gray tone colors. +(0) = black, (255) = white, (128) = gray. +This will only effect the W color element. + +### RgbwColor(RgbColor color); +Construct a RgbwColor using RgbColor, copying the R,G,B values and setting W to zero. + +### RgbwColor(HslColor color); +Construct a RgbwColor using HslColor, converting the Hsl to Rgbw + +### RgbwColor(HsbColor color); +Construct a RgbwColor using HsbColor, converting the Hsb to Rgbw + +### RgbwColor() +Construct a RgbwColor that will have its values set in latter operations. +CAUTION: The R,G,B,W members are not initialized and may not be consistent until set. + +## Methods +### uint8_t CalculateBrightness(); +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 an equal mix of the color components and the W. + +### void Darken(uint8_t delta); +Darken will adjust the color by the given delta toward black. +NOTE: This is a simple linear change. +delta - (0-255) the amount to dim the color by. + +### void Lighten(uint8_t delta); +Lighten will adjust the color by the given delta toward white. +NOTE: This is a simple linear change. If the color only has W value set, only W will be modified; otherwise only the R,G,B will be modified leaving W alone. +delta - (0-255) the amount to lighten the color by. + +### static RgbwColor LinearBlend(RgbwColor left, RgbwColor 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... +``` + RgbwColor results = RgbwColor::LinearBlend(RgbwColor(255,0,0,0), RgbwColor(0,255,0,10), 0.33f); +``` +