0

the philips hue bulb supports three different color models (temperature in mireds, hue/saturation, and cie1931).

since cie1931 is the 'native' model used by the bulb, most of the time that's the model reported by the bulb.

my naive thinking was to use d3.lab(1, cie1931.x, cie1931.y).rgb(), but this isn't right (all the colors come out very close to black).

could a color model guru point me in the direction of mapping cie1931[x,y] to one of the models supported by d3 ?

thanks!

4

2 回答 2

0

适用于 iOS 的 Philips Hue SDK 有一个应用说明,它解释了如何将 XY 值转换为 RGB。也许您可以根据自己的需要采用它。

于 2013-04-24T08:55:48.110 回答
-1
d3.cie1931 = {
// https://gist.github.com/AaronH/30c50aa4b161f8169c3d

  rgb : function(x, y) {
    var r, g, b, z;

    z = 1 - (x + y);

/*
   |R|   | X |   | 3.2333         -1.5262         0.2791 |
   |G| = | Y | * |-0.8268          2.4667         0.3323 |
   |B|   | Z |   | 0.1294          0.1983         2.0280 |
 */
    r =      (x *  3.2333) + (y * -1.5262) + (z * 0.2791);
    g =      (x * -0.8268) + (y *  2.4667) + (z * 0.3323);
    b =      (x *  0.1294) + (y *  0.1983) + (z * 2.0280);
    return d3.rgb (Math.max(0, Math.min(255, r * 255)),
                   Math.max(0, Math.min(255, g * 255)),
                   Math.max(0, Math.min(255, b * 255)));
  }
};
于 2013-04-17T02:56:00.137 回答