Argb32Color
Leave feedback
On this page
Inheritance: java.lang.Object
public class Argb32Color
Represents 32-bit color in ARGB format, with 8 bits per channel (Alpha, Red, Green, Blue). Supports transparency. Designed to be useful for (but not limited to) CSS operations. See more: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
| Constructor | Description |
|---|---|
| Argb32Color(int alpha, int red, int green, int blue) | Private constructor, initializes ARGB channels. |
| Field | Description |
|---|---|
| EMPTY | |
| TRANSPARENT |
| Method | Description |
|---|---|
| fromRgba(int red, int green, int blue, int alpha) | Create an Argb32Color from individual RGBA channels. |
| fromArgb(int argb) | Create an Argb32Color from a 32-bit ARGB int value (same as System.Drawing.Color.ToArgb()). |
| fromRgb(int red, int green, int blue) | Create an opaque Argb32Color from RGB channels (alpha = 255). |
| fromSingleValueRgb(int value) | Create a grayscale opaque Argb32Color from a single value applied to R, G, B. |
| getValue() | Gets the 32-bit signed integer representation of this color. |
| getAlpha() | Returns the alpha channel [0..255] |
| getAlphaFraction() | Returns the alpha channel as fraction [0..1] |
| getRed() | Returns the red channel [0..255] |
| getGreen() | Returns the green channel [0..255] |
| getBlue() | Returns the blue channel [0..255] |
| getArgbValue() | Returns the 32-bit ARGB integer value |
| isEmpty() | Indicates if this color is empty (all channels 0) |
| isDefault() | Indicates if instance is default (Transparent) - all 4 channels are set to 0. |
| isFullyTransparent() | Indicates if this color is fully transparent (alpha == 0) |
| isFullyOpaque() | Indicates if this color is fully opaque (alpha == 255) |
| isTranslucent() | Indicates if this color is translucent (alpha between 1 and 254) |
| getBrightness() | Calculates brightness/lightness of the color (HSL model). |
| getHue() | Calculates hue of the color in degrees [0..360]. |
| getSaturation() | Calculates saturation of the color (HSL model). |
| toArgb() | Returns the 32-bit ARGB value of this color instance, compatible with System.Drawing.Color.ToArgb() |
| toRGBA() | Serializes this Argb32Color instance to the ‘rgba’ CSS function notation. |
| toRGB() | Serializes this instance to CSS rgb() string notation (without alpha). |
| toHexRGBA() | Serializes this instance to hexadecimal #RRGGBBAA notation. |
| toHexRGB() | Serializes this instance to hexadecimal #RRGGBB notation (without alpha). |
| toString() | Returns the string representation using the most appropriate CSS notation. |
| equals(Object obj) | Equality comparison with another Argb32Color. |
| hashCode() | |
| equals(Argb32Color other) | Compares this color with another Argb32Color. |
| equals(Rgb24Color other) | Compares this color with a Rgb24Color. |
| toRgb24Color() | Cast this Argb32Color to Rgb24Color, losing alpha channel. |
| fromRgb24Color(Rgb24Color rgbColor) | Create Argb32Color from Rgb24Color with alpha set to 255. |
public Argb32Color(int alpha, int red, int green, int blue)
Private constructor, initializes ARGB channels.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| alpha | int | alpha channel (0-255) |
| red | int | red channel (0-255) |
| green | int | green channel (0-255) |
| blue | int | blue channel (0-255) |
public static final Argb32Color EMPTY
public static final Argb32Color TRANSPARENT
public static Argb32Color fromRgba(int red, int green, int blue, int alpha)
Create an Argb32Color from individual RGBA channels.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| red | int | |
| green | int | |
| blue | int | |
| alpha | int |
Returns: Argb32Color
public static Argb32Color fromArgb(int argb)
Create an Argb32Color from a 32-bit ARGB int value (same as System.Drawing.Color.ToArgb()).
Parameters:
| Parameter | Type | Description |
|---|---|---|
| argb | int |
Returns: Argb32Color
public static Argb32Color fromRgb(int red, int green, int blue)
Create an opaque Argb32Color from RGB channels (alpha = 255).
Parameters:
| Parameter | Type | Description |
|---|---|---|
| red | int | |
| green | int | |
| blue | int |
Returns: Argb32Color
public static Argb32Color fromSingleValueRgb(int value)
Create a grayscale opaque Argb32Color from a single value applied to R, G, B.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | int |
Returns: Argb32Color
public int getValue()
Gets the 32-bit signed integer representation of this color. This value is typically used as a packed ARGB value.
Returns: int - The 32-bit integer value representing the color.
public int getAlpha()
Returns the alpha channel [0..255]
Returns: int
public double getAlphaFraction()
Returns the alpha channel as fraction [0..1]
Returns: double
public int getRed()
Returns the red channel [0..255]
Returns: int
public int getGreen()
Returns the green channel [0..255]
Returns: int
public int getBlue()
Returns the blue channel [0..255]
Returns: int
public int getArgbValue()
Returns the 32-bit ARGB integer value
Returns: int
public boolean isEmpty()
Indicates if this color is empty (all channels 0)
Returns: boolean
public boolean isDefault()
Indicates if instance is default (Transparent) - all 4 channels are set to 0.
Returns: boolean
public boolean isFullyTransparent()
Indicates if this color is fully transparent (alpha == 0)
Returns: boolean
public boolean isFullyOpaque()
Indicates if this color is fully opaque (alpha == 255)
Returns: boolean
public boolean isTranslucent()
Indicates if this color is translucent (alpha between 1 and 254)
Returns: boolean
public float getBrightness()
Calculates brightness/lightness of the color (HSL model).
Returns: float - float in [0..1]
public float getHue()
Calculates hue of the color in degrees [0..360]. Returns 0 if color is grayscale (R=G=B).
Returns: float
public float getSaturation()
Calculates saturation of the color (HSL model).
Returns: float - float in [0..1]
public int toArgb()
Returns the 32-bit ARGB value of this color instance, compatible with System.Drawing.Color.ToArgb()
Returns: int
public String toRGBA()
Serializes this Argb32Color instance to the ‘rgba’ CSS function notation.
Returns: java.lang.String - A string formatted as ‘rgba(r, g, b, a)’.
public String toRGB()
Serializes this instance to CSS rgb() string notation (without alpha).
Returns: java.lang.String
public String toHexRGBA()
Serializes this instance to hexadecimal #RRGGBBAA notation.
Returns: java.lang.String
public String toHexRGB()
Serializes this instance to hexadecimal #RRGGBB notation (without alpha).
Returns: java.lang.String
public String toString()
Returns the string representation using the most appropriate CSS notation.
Returns: java.lang.String
public boolean equals(Object obj)
Equality comparison with another Argb32Color.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| obj | java.lang.Object |
Returns: boolean
public int hashCode()
Returns: int
public boolean equals(Argb32Color other)
Compares this color with another Argb32Color.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| other | Argb32Color |
Returns: boolean
public boolean equals(Rgb24Color other)
Compares this color with a Rgb24Color.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| other | Rgb24Color |
Returns: boolean
public Rgb24Color toRgb24Color()
Cast this Argb32Color to Rgb24Color, losing alpha channel.
Returns: Rgb24Color
public static Argb32Color fromRgb24Color(Rgb24Color rgbColor)
Create Argb32Color from Rgb24Color with alpha set to 255.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| rgbColor | Rgb24Color |
Returns: Argb32Color
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.