public double getR() { return getRed() / 255.0D; }
public Color(double red, double green, double blue, double alpha) { this.alpha = (int) (Math.min(1.0D, Math.max(0.0D, alpha)) * 0xFF); this.blue = (int) (Math.min(1.0D, Math.max(0.0D, blue)) * 0xFF); this.green = (int) (Math.min(1.0D, Math.max(0.0D, green)) * 0xFF); this.red = (int) (Math.min(1.0D, Math.max(0.0D, red)) * 0xFF); this.hash = getAlpha() << 24 | getRed() << 16 | getGreen() << 8 | getBlue(); }
@Nonnull public static Color createDirect(@Nonnull Color mainColor, int alpha) { return new Color(mainColor.getRed(), mainColor.getGreen(), mainColor.getBlue(), alpha); } }
@Nonnull public static float[] asHSB(@Nonnull Color color) { return asHSB(color.getRed(), color.getGreen(), color.getBlue()); }
@Nonnull public IntBuffer createIntBuffer() { IntBuffer buffer = Bufferer.newIntBuffer(4); buffer.put(getRed()); buffer.put(getGreen()); buffer.put(getBlue()); buffer.put(getAlpha()); buffer.flip(); return buffer; }
@Nonnull public int[] createRgba() { return new int[] { getRed(), getGreen(), getBlue(), getAlpha() }; }
@Nonnull public Color inverse() { return new Color(255 - getRed(), 255 - getGreen(), 255 - getBlue(), 255 - getAlpha()); }