HSBType extends PercentType implements ComplexType, State, Command { public static HSBType fromXY(float x, float y) { float tmpY = 1.0f; float tmpX = (tmpY / y) * x; float tmpZ = (tmpY / y) * (1.0f - x - y); float r = tmpX * XY2RGB[0][0] + tmpY * XY2RGB[0][1] + tmpZ * XY2RGB[0][2]; float g = tmpX * XY2RGB[1][0] + tmpY * XY2RGB[1][1] + tmpZ * XY2RGB[1][2]; float b = tmpX * XY2RGB[2][0] + tmpY * XY2RGB[2][1] + tmpZ * 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)); } HSBType();  HSBType(DecimalType h, PercentType s, PercentType b);  HSBType(String value); static HSBType valueOf(String value); static HSBType fromRGB(int r, int g, int b); static HSBType fromXY(float x, float y); @Override SortedMap<String, PrimitiveType> getConstituents(); DecimalType getHue(); PercentType getSaturation(); PercentType getBrightness(); PercentType getRed(); PercentType getGreen(); PercentType getBlue(); int getRGB(); @Override String toString(); @Override String toFullString(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); PercentType[] toRGB(); PercentType[] toXY(); @Override T as(@Nullable Class<T> target); static final String KEY_HUE; static final String KEY_SATURATION; static final String KEY_BRIGHTNESS; static final HSBType BLACK; static final HSBType WHITE; static final HSBType RED; static final HSBType GREEN; static final HSBType BLUE; }
@Test public void testCreateFromXY() { HSBType hsb = HSBType.fromXY(5f, 3f); assertEquals(new HSBType("11,100,100"), hsb); }