Updated HtmlColor object API (markdown)

Michael Miller
2016-07-04 13:30:49 -07:00
parent 2cf2e864d9
commit 0b315f7855

@@ -33,30 +33,37 @@ c11 - lower right quadrant color
x - unit value (0.0 - 1.0) that defines the blend progress in horizontal space 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 y - unit value (0.0 - 1.0) that defines the blend progress in vertical space
### size_t Parse(const char* name, size_t nameSize); ### template \<typename T_HTMLCOLORNAMES\> size_t Parse(const char* name, size_t nameSize);
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. 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. 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. 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. returns - the count of chars parsed (excludes null terminator). Add this to name to get the next char after the parsed value.
**NOTE:** - by default a short list of standard names are used to conserve flash memory. If the full CSS3 set is required, currently you will be required to find and edit the "HtmlColor.h" file, uncomment the following line example:
``` ```
// #define USE_CSS3_COLORS 1 HtmlColor color;
uint8_t result = color.Parse<HtmlColorNames>(buf, bufSize);
``` ```
### size_t Parse(const char* name); ### template \<typename T_HTMLCOLORNAMES\> size_t Parse(const char* name);
Alternative to Parse above, the string MUST be null terminated. Alternative to Parse above, the string MUST be null terminated.
### size_t Parse(String const &name); ### template \<typename T_HTMLCOLORNAMES\> size_t Parse(String const &name);
Alternative to Parse above, takes a standard String object instead. Alternative to Parse above, takes a standard String object instead.
### size_t ToString(char* buf, size_t bufSize) const; ### template \<typename T_HTMLCOLORNAMES\> size_t ToString(char* buf, size_t bufSize) const;
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. 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. buf - the buffer to write the string into.
bufSize - the size of the buf, room must be provided for a null terminator. bufSize - the size of the buf, room must be provided for a null terminator.
returns - the number of chars written into the buffer. returns - the number of chars written into the buffer.
**NOTE:** - by default a short list of standard names are used to conserve flash memory. If the full CSS3 set is required, currently you will be required to find and edit the "HtmlColor.h" file, uncomment the following line
example:
``` ```
// #define USE_CSS3_COLORS 1 HtmlColor color;
color.ToString<HtmlShortColorNames>(buf, bufSize);
``` ```
### size_t ToNumericalString(char* buf, size_t bufSize) const; ### size_t ToNumericalString(char* buf, size_t bufSize) const;