3

在https://github.com/InfinitApps/InfColorPicker/blob/master/InfColorPicker/InfHSBSupport.m的帮助下为 Philip 的 Hue 灯实现了彩色光调色板

在此处输入图像描述

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;
}

有没有办法为菲利普的色调光实现白色调色板,如下图所示?

在此处输入图像描述

4

0 回答 0