Class ColorRGB


  • public final class ColorRGB
    extends java.lang.Object
    Represents a color built out of red, green, and blue components. The color components have a value between 0 and 255, where (0, 0, 0) is black and (255, 255, 255) is white.
    • Constructor Detail

      • ColorRGB

        public ColorRGB​(int r,
                        int g,
                        int b)
        Creates a color from the specified red, green, and blue components.
        Throws:
        java.lang.IllegalArgumentException - if one of the color components is outside the range 0-255.
      • ColorRGB

        public ColorRGB​(int rgba)
        Creates a color from a single RGBA value. The value's alpha component will be ignored.
    • Method Detail

      • getR

        public int getR()
      • getG

        public int getG()
      • getB

        public int getB()
      • getRGB

        public int getRGB()
      • 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
      • toHex

        public java.lang.String toHex()
        Returns this color in hexidecimal notation. For example, the color red (255, 0, 0) will return "#FF0000".
      • parseHex

        public static ColorRGB parseHex​(java.lang.String hex)
        Parses a color from hexadecimal notation. For example, parsing the string "#FF0000" will return red (255, 0, 0).
        Throws:
        java.lang.IllegalArgumentException - if hex is not a valid color.