Class ColorRGB
- java.lang.Object
-
- nl.colorize.multimedialib.graphics.ColorRGB
-
public final class ColorRGB extends java.lang.ObjectRepresents 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)intgetB()intgetG()intgetR()intgetRGB()inthashCode()static ColorRGBparseHex(java.lang.String hex)Parses a color from hexadecimal notation.java.lang.StringtoHex()Returns this color in hexidecimal notation.java.lang.StringtoString()
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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- ifhexis not a valid color.
-
-