Rgb24Color
Leave feedback
On this page
Inheritance: java.lang.Object
public class Rgb24Color
| Constructor | Description |
|---|---|
| Rgb24Color(int r, int g, int b) | Private constructor to create a color from red, green, and blue channels. |
| 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() |
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 |
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
public int getR()
Gets the red channel value.
Returns: int - Red channel [0..255]
public int getG()
Gets the green channel value.
Returns: int - Green channel [0..255]
public int getB()
Gets the blue channel value.
Returns: int - Blue channel [0..255]
public boolean isDefault()
Returns true if the color is the default black color (all channels are zero).
Returns: boolean - True if black, otherwise false
public float getBrightness()
Calculates the brightness (lightness) of this color in HSL color space.
Returns: float - Brightness as a float in range [0..1]
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)
public float getSaturation()
Calculates the saturation of this color in HSL color space.
Returns: float - Saturation as a float in range [0..1]
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
public int hashCode()
Returns: int
public boolean equals(Object obj)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| obj | java.lang.Object |
Returns: boolean
public String toRGB()
Returns the CSS rgb() function string representation of the color.
Returns: java.lang.String - String in format “rgb(r, g, b)”
public String toHex()
Returns the hexadecimal string representation of the color.
Returns: java.lang.String - String in format “#RRGGBB”
public String toString()
Returns: java.lang.String
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.