3

Implemented Coloured light palette for Philip's Hue light with the help of https://github.com/InfinitApps/InfColorPicker/blob/master/InfColorPicker/InfHSBSupport.m

enter image description here

UInt8 r_s = (UInt8) ((1.0f - r) * 255);
UInt8 g_s = (UInt8) ((1.0f - g) * 255);
UInt8 b_s = (UInt8) ((1.0f - b) * 255);

for (int s = 0; s < 256; ++s) {
    register UInt8* ptr = dataPtr;

    register unsigned int r_hs = 255 - blend(s, r_s);
    register unsigned int g_hs = 255 - blend(s, g_s);
    register unsigned int b_hs = 255 - blend(s, b_s);

    for (register int v = 255; v >= 0; --v) {
        ptr[0] = (UInt8) (v * b_hs >> 8);
        ptr[1] = (UInt8) (v * g_hs >> 8);
        ptr[2] = (UInt8) (v * r_hs >> 8);

        // Really, these should all be of the form used in blend(),
        // which does a divide by 255. However, integer divide is
        // implemented in software on ARM, so a divide by 256
        // (done as a bit shift) will be *nearly* the same value,
        // and is faster. The more-accurate versions would look like:
        //  ptr[0] = blend(v, b_hs);

        ptr += rowBytes;
    }

    dataPtr += 4;
}

Is there any way to implement White colour palette for Philip's hue light like in the below image?

enter image description here

swathy krishnan
  • 916
  • 9
  • 22
Alen Alexander
  • 725
  • 6
  • 22

0 Answers0