Class RGBColor

  • All Implemented Interfaces:
    Color

    public class RGBColor
    extends java.lang.Object
    implements Color
    Red/Green/Blue

    The red, green, blue, and alpha components should be between [0,255].

    • Field Detail

      • red

        public final int red
      • green

        public final int green
      • blue

        public final int blue
      • alpha

        public final int alpha
    • Constructor Detail

      • RGBColor

        public RGBColor​(int red,
                        int green,
                        int blue)
        Creates an RGB with default alpha of 255.
      • RGBColor

        public RGBColor​(int red,
                        int green,
                        int blue,
                        int alpha)
    • Method Detail

      • fromARGBInt

        public static RGBColor fromARGBInt​(int argb)
      • fromRGBInt

        public static RGBColor fromRGBInt​(int rgb)
      • fromAwt

        public static RGBColor fromAwt​(java.awt.Color color)
      • fromRGB

        public static RGBColor fromRGB​(int[] rgb)
      • toInt

        @Deprecated
        public int toInt()
        Deprecated.
        Returns as an int the value of this color. The RGB and alpha components are packed as rgba. Use toARGBInt() for clarity.
      • toARGBInt

        public int toARGBInt()
      • toRGB

        public RGBColor toRGB()
        Description copied from interface: Color
        Returns a conversion of this Color into an RGBColor. If this colour is already an instance of RGBColor then the same instance will be returned.
        Specified by:
        toRGB in interface Color
      • withRed

        public RGBColor withRed​(int r)
      • withBlue

        public RGBColor withBlue​(int b)
      • withGreen

        public RGBColor withGreen​(int g)
      • average

        public int average()
      • toArray

        public int[] toArray()
      • toCMYK

        public CMYKColor toCMYK()
        Returns a conversion of this color into a CYMK color. If this colour is already a CYMK then the same instance will be returned.
        Specified by:
        toCMYK in interface Color
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object