Package com.github.miachm.sods
Class Color
java.lang.Object
com.github.miachm.sods.Color
- All Implemented Interfaces:
Cloneable
Color is a inmutable class for represent colors.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Color
public Color(int red, int green, int blue) It creates a color object from a RGB format (red, green, blue).- Parameters:
red- the red color intensity. It must be in a 0-255 rangegreen- the green color intensity. It must be in a 0-255 rangeblue- the blue color intensity. It must be in a 0-255 range
-
Color
It creates a color object from a String representation (CSS Style). The first character is the hashtag '#' The next two characters are the red intensity in hex (ex: A4) The next two characters are the green intensity in hex (ex: 3B) The next two characters are the blue intensity in hex (ex: 53)- Parameters:
hexform- The string representation of the color. For example: "#A24C21"- Throws:
IllegalArgumentException- if the string hasn't 7 characters or is ill-formed
-
-
Method Details
-
getRed
public int getRed() -
getBlue
public int getBlue() -
getGreen
public int getGreen() -
toString
A string representation of the color -
equals
-
hashCode
public int hashCode() -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-