Package com.oorian.css.color
Class Rgb
java.lang.Object
com.oorian.css.color.Rgb
- All Implemented Interfaces:
Serializable
This class encapsulates the attributes used for setting an RGB color.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
r
public int rRed color component (0 - 255). -
g
public int gGreen color component (0 - 255). -
b
public int bBlue color component (0 - 255). -
a
public float aAlpha component (0.0 = fully transparent, 1.0 = fully opaque).
-
-
Constructor Details
-
Rgb
public Rgb()Creates a default RGB object with RGB = 0, 0, 0 and alpha = 1.0. -
Rgb
public Rgb(int r, int g, int b) Creates an RGB object with the specified RGB values and alpha = 1.0.- Parameters:
r- Red color component (0 - 255)g- Green color component (0 - 255)b- Blue color component (0 - 255)
-
Rgb
public Rgb(int r, int g, int b, float a) Creates an RGBA object with the specified RGB and alpha values.- Parameters:
r- Red color component (0 - 255)g- Green color component (0 - 255)b- Blue color component (0 - 255)a- Alpha component (0.0 - 1.0)
-
Rgb
- Parameters:
rgb- Copy constructor.
-
-
Method Details
-
getRgb
public int getRgb()Returns the RGB value as a single integer with components packed as 0xRRGGBB.- Returns:
- The RGB value with red in bits 16-23, green in bits 8-15, and blue in bits 0-7.
-
hasAlpha
public boolean hasAlpha()Returns whether this color has a non-opaque alpha value.- Returns:
- true if the alpha component is less than 1.0.
-
toString
This method returns a String representation of this object. -
equals
-
hashCode
public int hashCode()
-