From 085a87ffabb711af67e60d771ece832a84613f53 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 26 Feb 2016 10:03:01 -0800 Subject: [PATCH] Updated FAQ (markdown) --- FAQ.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/FAQ.md b/FAQ.md index b893549..8325c9e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -19,4 +19,33 @@ NeoPixelBus* Strip = NULL; // other parts of your code, you set the colors, and show Strip->SetPixelColor(0, RgbColor(0)); Strip->Show(); +``` +### How can I convert Hsl to Rgb and/or just set the colors with Hsl? +There is a HslColor object that will automatically convert to any of the other color object by just assigning them. +``` + HslColor myColor(244.0f, 1.0f, 0.5f); + RgbColor rgbOfMyColor = myColor; +``` +Further, all the color objects can be used by the SetPixelColor(). +``` + HslColor myColor(244.0f, 1.0f, 0.5f); + strip.SetPixelColor(0, myColor); +``` +The only limitation is that the RgbwColor can not be used directly with a NeoPixelBus defined with a 3 element feature like NeoRgbFeature or NeoGrbFeature. This is due to the loss of color that could happen. So the following will create a compile error. +``` + NeoPixelBus strip(2,2); +... + RgbwColor myColor(124, 64, 124, 10); + strip.SetPixelColor(0, myColor); // compiler error +``` +The issue is what does it mean to convert RGBW value to just RGB? How is the white handled in the conversion? There is no standard to how this should be done so it is left to you for your application. +You could just ignore the white like below. +``` + RgbwColor myColor(124, 64, 124, 10); + RgbColor myRgbColor(myColor.R, myColor.G, myColor.B); // converted ignore the white +``` +Or you could blend the white in as demonstrated by this simple example. +``` + RgbwColor myColor(124, 64, 124, 10); + RgbColor myRgbColor(myColor.R + myColor.W, myColor.G + myColor.W, myColor.B + myColor.W); // blend in white ``` \ No newline at end of file