From d8a7fb55d1f55342f06d28c47a5dca285d2312dc Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 27 Mar 2016 12:48:45 -0700 Subject: [PATCH] Created FAQ #6 (markdown) --- FAQ-#6.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 FAQ-#6.md diff --git a/FAQ-#6.md b/FAQ-#6.md new file mode 100644 index 0000000..a5d927e --- /dev/null +++ b/FAQ-#6.md @@ -0,0 +1,22 @@ +### Is there a way to specify a color using a color wheel? +The color wheel routines you may have seen in other code is really a hack of the core feature of HSL or HSB(HSV) color space. The number often represented in degrees of 0 to 360 is actually the Hue value for this alternate color spaces. Its called a color wheel as these color spaces are often displayed as a wheel as their target audience was visual designers and not engineers. + +NOTE: There is no HsvColor in my library, as HsbColor is really the same thing. + +You can thus just use the HslColor or HsbColor objects to accomplish this. In the case of my library, the Hue value range is 0.0 to 1.0 instead of 0 to 360, so some minor math will correct that. +``` + RgbColor WheelColor(uint16_t wheelValue) { + // divide the wheelValue by 360.0f to get a value between 0.0 and 1.0 needed for HslColor + return HslColor(wheelValue / 360.0f, 1.0f, 0.5f); // this will autoconvert back to RgbColor + } + +// latter in the code + + RgbColor newColor = WheelColor(277); + strip.SetPixelColor(0, newColor); +``` +The better approach is retrain yourself that when you see a wheel value, it means Hue. So you just use either HslColor or HsbColor in the first place. +``` + HslColor newColor(277/360.0f, 1.0f, 0.5f); + strip.SetPixelColor(0, newColor); +``` \ No newline at end of file