public PercentType getBlue() { return toRGB()[2]; }
public PercentType getRed() { return toRGB()[0]; }
public PercentType getGreen() { return toRGB()[1]; }
/** * Returns the RGB value representing the color in the default sRGB * color model. * (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue). * * @return the RGB value of the color in the default sRGB color model */ public int getRGB() { PercentType[] rgb = toRGB(); return ((0xFF) << 24) | ((convertPercentToByte(rgb[0]) & 0xFF) << 16) | ((convertPercentToByte(rgb[1]) & 0xFF) << 8) | ((convertPercentToByte(rgb[2]) & 0xFF) << 0); }
/** * Returns the xyY values representing this object's color in CIE XY color model. * Conversion from sRGB to CIE XY using D65 reference white * xy pair contains color information * Y represents relative luminance * * @param HSBType color object * @return PercentType[x, y, Y] values in the CIE XY color model */ public PercentType[] toXY() { // This makes sure we keep color information even if brightness is zero PercentType sRGB[] = new HSBType(getHue(), getSaturation(), PercentType.HUNDRED).toRGB(); float r = gammaDecompress(sRGB[0].floatValue() / 100.0f); float g = gammaDecompress(sRGB[1].floatValue() / 100.0f); float b = gammaDecompress(sRGB[2].floatValue() / 100.0f); float X = r * Rgb2Xy[0][0] + g * Rgb2Xy[0][1] + b * Rgb2Xy[0][2]; float Y = r * Rgb2Xy[1][0] + g * Rgb2Xy[1][1] + b * Rgb2Xy[1][2]; float Z = r * Rgb2Xy[2][0] + g * Rgb2Xy[2][1] + b * Rgb2Xy[2][2]; float x = X / (X + Y + Z); float y = Y / (X + Y + Z); return new PercentType[] { new PercentType(Float.valueOf(x * 100.0f).toString()), new PercentType(Float.valueOf(y * 100.0f).toString()), new PercentType(Float.valueOf(Y * getBrightness().floatValue()).toString()) }; }
public PercentType getGreen() { return toRGB()[1]; }
public PercentType getRed() { return toRGB()[0]; }
public PercentType getBlue() { return toRGB()[2]; }
/** * Returns the RGB value representing the color in the default sRGB * color model. * (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue). * * @return the RGB value of the color in the default sRGB color model */ public int getRGB() { PercentType[] rgb = toRGB(); return ((0xFF) << 24) | ((convertPercentToByte(rgb[0]) & 0xFF) << 16) | ((convertPercentToByte(rgb[1]) & 0xFF) << 8) | ((convertPercentToByte(rgb[2]) & 0xFF) << 0); }
/** * Returns the xyY values representing this object's color in CIE XY color model. * Conversion from sRGB to CIE XY using D65 reference white * xy pair contains color information * Y represents relative luminance * * @param HSBType color object * @return PercentType[x, y, Y] values in the CIE XY color model */ public PercentType[] toXY() { // This makes sure we keep color information even if brightness is zero PercentType sRGB[] = new HSBType(getHue(), getSaturation(), PercentType.HUNDRED).toRGB(); float r = gammaDecompress(sRGB[0].floatValue() / 100.0f); float g = gammaDecompress(sRGB[1].floatValue() / 100.0f); float b = gammaDecompress(sRGB[2].floatValue() / 100.0f); float X = r * Rgb2Xy[0][0] + g * Rgb2Xy[0][1] + b * Rgb2Xy[0][2]; float Y = r * Rgb2Xy[1][0] + g * Rgb2Xy[1][1] + b * Rgb2Xy[1][2]; float Z = r * Rgb2Xy[2][0] + g * Rgb2Xy[2][1] + b * Rgb2Xy[2][2]; float x = X / (X + Y + Z); float y = Y / (X + Y + Z); return new PercentType[] { new PercentType(Float.valueOf(x * 100.0f).toString()), new PercentType(Float.valueOf(y * 100.0f).toString()), new PercentType(Float.valueOf(Y * getBrightness().floatValue()).toString()) }; }