MCPcopy Create free account
hub / github.com/Makuna/NeoPixelBus / ToNumericalString

Method ToNumericalString

src/internal/colors/HtmlColor.cpp:46–63  ·  view source on GitHub ↗

* Generates a Html encoded hex color string (#aabbcc) with null termination. * * @param buf the buffer to write the string to * @param bufSize the maximum buffer size (must be at least 8 characters) * @return The amount of chars written to buf including the null terminator. */

Source from the content-addressed store, hash-verified

44 * @return The amount of chars written to buf including the null terminator.
45 */
46size_t HtmlColor::ToNumericalString(char* buf, size_t bufSize) const
47{
48 if (bufSize >= 8)
49 {
50 buf[0] = '#';
51
52 uint32_t color = Color;
53 for (size_t indexDigit = 6; indexDigit > 0; --indexDigit) // note pre-decrement
54 {
55 buf[indexDigit] = hexdigit(color & 0x0000000f);
56 color >>= 4;
57 }
58 buf[7] = '\0';
59
60 return 8;
61 }
62 return 0;
63}

Callers

nothing calls this directly

Calls 1

hexdigitFunction · 0.85

Tested by

no test coverage detected