Philip's Hue - палитра белого света - реализация iOS

Реализована цветная световая палитра для освещения Филиппа Хью с помощью https://github.com/InfinitApps/InfColorPicker/blob/master/InfColorPicker/InfHSBSupport.m

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

Есть ли способ реализовать белую цветовую палитру для оттенка Филиппа, как на картинке ниже?

0 ответов

Другие вопросы по тегам