-
-
Notifications
You must be signed in to change notification settings - Fork 265
HtmlColor object API
HtmlColor represents a color object that uses the Html color value standard that is represented by a single uint32_t. The primary use of this class is to convert to other color objects.
NOTE: HtmlColor has no concept of W channels. It can be converted to RGB, but when converted to RGBW, RGBWW, and RGBWWW the W channels will always be empty.
Below is an example that will create a RgbColor with the Html color value for yellow.
RgbColor yellow( HtmlColor( 0xffff00 ) );
There is one property that represents the coded component values Red, Green, and Blue. The values range from 0 to 0xffffff. Black would 0 and white would be 0xffffff.
This value is three coded bytes of red, green, blue component values. The value 0xff7f10 decoded is red = 255 (0xff), green = 127 (x7f), and blue = 16 (0x10).
uint32_t Color;
Constructs a HtmlColor using the given value.
- color - a 24-bit value stored within a uint32_t in RGB order.
Construct a HtmlColor using a RgbColor , converting the Rgb component values to the single Html value.
- color - a RgbColor object.
Construct a HtmlColor that will have its values set in latter operations.
CAUTION: The Color member is not initialized and may not be consistent until set.
static HtmlColor BilinearBlend(HtmlColor c00, HtmlColor c01, HtmlColor c10, HtmlColor 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.
This will parse the given string and set the color based on the value. The string is expected to be in a HTML4/CSS3 supported format.
T_HTMLCOLORNAMES - a HtmlColorName object (either HtmlColorNames or HtmlShortColorNames) that defines the collection of color names to use. HtmlColorNames will consume more program space as it contains the full set of standard names.
- name - the string to parse, ending at either null terminated, non-alphanumeric delimited, or nameSize count.
- nameSize - the size of the name buffer, max number of chars to parse.
- <returns> - the count of chars parsed (excludes null terminator). Add this to name to get the next char after the parsed value.
example:
HtmlColor color;
uint8_t result = color.Parse<HtmlColorNames>(buf, bufSize);
Alternative to Parse above, the string MUST be null terminated.
Alternative to Parse above, takes a standard String object instead.
This will convert the color value to a standard HTML/CSS3 color string. If a standard friendly name is available it will use it; otherwise it will provide a numerical "#hhhhhh" formatted string.
T_HTMLCOLORNAMES - a HtmlColorName object (either HtmlColorNames or HtmlShortColorNames) that defines the collection of color names to use. HtmlColorNames will consume more program space as it contains the full set of standard names.
- buf - the buffer to write the string into.
- bufSize - the size of the buf, room must be provided for a null terminator.
- <returns> - the number of chars written into the buffer.
example:
HtmlColor color;
color.ToString<HtmlShortColorNames>(buf, bufSize);
This will convert the color value to a standard HTML/CSS3 color string. It will always provide a numerical "#hhhhhh" formatted string.
- buf - the buffer to write the string into.
- bufSize - the size of the buf, room must be provided for a null terminator.
- <returns> - the number of chars written into the buffer.