Rgb24Color
Inheritance: java.lang.Object
public class Rgb24Color
Constructors
| Constructor | Description |
|---|---|
| Rgb24Color(int r, int g, int b) | Private constructor to create a color from red, green, and blue channels. |
Methods
| Method | Description |
|---|---|
| fromRgb(int red, int green, int blue) | Creates a new Rgb24Color from specified red, green, and blue channel values. |
| getR() | Gets the red channel value. |
| getG() | Gets the green channel value. |
| getB() | Gets the blue channel value. |
| isDefault() | Returns true if the color is the default black color (all channels are zero). |
| getBrightness() | Calculates the brightness (lightness) of this color in HSL color space. |
| getHue() | Calculates the hue of this color in degrees (HSL color space). |
| getSaturation() | Calculates the saturation of this color in HSL color space. |
| toArgb() | Returns the 32-bit ARGB representation of this color. |
| hashCode() | |
| equals(Object obj) | |
| toRGB() | Returns the CSS rgb() function string representation of the color. |
| toHex() | Returns the hexadecimal string representation of the color. |
| toString() |
Rgb24Color(int r, int g, int b)
public Rgb24Color(int r, int g, int b)
Private constructor to create a color from red, green, and blue channels. Values are clamped to the [0..255] range.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| r | int | |
| g | int | |
| b | int |
fromRgb(int red, int green, int blue)
public static Rgb24Color fromRgb(int red, int green, int blue)
Creates a new Rgb24Color from specified red, green, and blue channel values. The input values are clamped to the valid range [0..255].
Parameters:
| Parameter | Type | Description |
|---|---|---|
| red | int | Red channel value |
| green | int | Green channel value |
| blue | int | Blue channel value |
Returns: Rgb24Color - New Rgb24Color instance
getR()
public int getR()
Gets the red channel value.
Returns: int - Red channel [0..255]
getG()
public int getG()
Gets the green channel value.
Returns: int - Green channel [0..255]
getB()
public int getB()
Gets the blue channel value.
Returns: int - Blue channel [0..255]
isDefault()
public boolean isDefault()
Returns true if the color is the default black color (all channels are zero).
Returns: boolean - True if black, otherwise false
getBrightness()
public float getBrightness()
Calculates the brightness (lightness) of this color in HSL color space.
Returns: float - Brightness as a float in range [0..1]
getHue()
public float getHue()
Calculates the hue of this color in degrees (HSL color space). Returns 0 if the color is grayscale (red = green = blue).
Returns: float - Hue in degrees [0..360)
getSaturation()
public float getSaturation()
Calculates the saturation of this color in HSL color space.
Returns: float - Saturation as a float in range [0..1]
toArgb()
public int toArgb()
Returns the 32-bit ARGB representation of this color. Alpha is always set to 255 (fully opaque).
Returns: int - ARGB color as int
hashCode()
public int hashCode()
Returns: int
equals(Object obj)
public boolean equals(Object obj)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| obj | java.lang.Object |
Returns: boolean
toRGB()
public String toRGB()
Returns the CSS rgb() function string representation of the color.
Returns: java.lang.String - String in format “rgb(r, g, b)”
toHex()
public String toHex()
Returns the hexadecimal string representation of the color.
Returns: java.lang.String - String in format “#RRGGBB”
toString()
public String toString()
Returns: java.lang.String