/** * Returns a HSBType object representing the provided xy color values in CIE XY color model. * Conversion from CIE XY color model to sRGB using D65 reference white * Returned color is set to full brightness * * @param x, y color information 0.0 - 1.0 * * @return new HSBType object representing the given CIE XY color, full brightness */ public static HSBType fromXY(float x, float y) { float Yo = 1.0f; float X = (Yo / y) * x; float Z = (Yo / y) * (1.0f - x - y); float r = X * Xy2Rgb[0][0] + Yo * Xy2Rgb[0][1] + Z * Xy2Rgb[0][2]; float g = X * Xy2Rgb[1][0] + Yo * Xy2Rgb[1][1] + Z * Xy2Rgb[1][2]; float b = X * Xy2Rgb[2][0] + Yo * Xy2Rgb[2][1] + Z * Xy2Rgb[2][2]; float max = r > g ? r : g; if (b > max) { max = b; } r = gammaCompress(r / max); g = gammaCompress(g / max); b = gammaCompress(b / max); return HSBType.fromRGB((int) (r * 255.0f + 0.5f), (int) (g * 255.0f + 0.5f), (int) (b * 255.0f + 0.5f)); }
int green = colorMap.get(ZWaveColorType.GREEN) != null ? colorMap.get(ZWaveColorType.GREEN) : 0; int blue = colorMap.get(ZWaveColorType.BLUE) != null ? colorMap.get(ZWaveColorType.BLUE) : 0; state = HSBType.fromRGB(red, green, blue); break; case PercentType:
/** * Returns a HSBType object representing the provided xy color values in CIE XY color model. * Conversion from CIE XY color model to sRGB using D65 reference white * Returned color is set to full brightness * * @param x, y color information 0.0 - 1.0 * * @return new HSBType object representing the given CIE XY color, full brightness */ public static HSBType fromXY(float x, float y) { float Yo = 1.0f; float X = (Yo / y) * x; float Z = (Yo / y) * (1.0f - x - y); float r = X * Xy2Rgb[0][0] + Yo * Xy2Rgb[0][1] + Z * Xy2Rgb[0][2]; float g = X * Xy2Rgb[1][0] + Yo * Xy2Rgb[1][1] + Z * Xy2Rgb[1][2]; float b = X * Xy2Rgb[2][0] + Yo * Xy2Rgb[2][1] + Z * Xy2Rgb[2][2]; float max = r > g ? r : g; if (b > max) { max = b; } r = gammaCompress(r / max); g = gammaCompress(g / max); b = gammaCompress(b / max); return HSBType.fromRGB((int) (r * 255.0f + 0.5f), (int) (g * 255.0f + 0.5f), (int) (b * 255.0f + 0.5f)); }
Expression the = opt("the"); Expression to = opt("to"); Expression color = alt(cmd("white", HSBType.WHITE), cmd("pink", HSBType.fromRGB(255, 96, 208)), cmd("yellow", HSBType.fromRGB(255, 224, 32)), cmd("orange", HSBType.fromRGB(255, 160, 16)), cmd("purple", HSBType.fromRGB(128, 0, 128)), cmd("red", HSBType.RED), cmd("green", HSBType.GREEN), cmd("blue", HSBType.BLUE)); Expression naechste = alt("nächste", "nächstes", "nächster"); Expression vorherige = alt("vorherige", "vorheriges", "vorheriger"); Expression farbe = alt(cmd("weiß", HSBType.WHITE), cmd("pink", HSBType.fromRGB(255, 96, 208)), cmd("gelb", HSBType.fromRGB(255, 224, 32)), cmd("orange", HSBType.fromRGB(255, 160, 16)), cmd("lila", HSBType.fromRGB(128, 0, 128)), cmd("rot", HSBType.RED), cmd("grün", HSBType.GREEN), cmd("blau", HSBType.BLUE)); Expression lela = opt(alt("le", "la", "les", "l")); Expression poursurdude = opt(alt("pour", "sur", "du", "de")); Expression couleur = alt(cmd("blanc", HSBType.WHITE), cmd("rose", HSBType.fromRGB(255, 96, 208)), cmd("jaune", HSBType.fromRGB(255, 224, 32)), cmd("orange", HSBType.fromRGB(255, 160, 16)), cmd("violet", HSBType.fromRGB(128, 0, 128)), cmd("rouge", HSBType.RED), cmd("vert", HSBType.GREEN), cmd("bleu", HSBType.BLUE));