Class Color
java.lang.Object
org.strassburger.colorlab4j.color.Color
Abstract representation of a color.
Provides methods to convert between different color spaces.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorGet the color from a hex stringstatic HSLColorhsl(double h, double s, double l) Create an HSL colorstatic HSVColorhsv(double h, double s, double v) Create an HSV colorstatic LABColorlab(double l, double a, double b) Create a LAB colorstatic RGBColorrgb(int r, int g, int b) Create an RGB colortoAnsi()Get the ANSI representation of the colorGet the ANSI representation of the color for the backgroundabstract StringGet the CSS representation of the colortoHex()Get the hex representation of the colorabstract HSLColortoHSL()Convert the color to HSLabstract HSVColortoHSV()Convert the color to HSVabstract LABColortoLAB()Convert the color to LABabstract RGBColortoRGB()Convert the color to RGBabstract XYZColortoXYZ()Convert the color to XYZstatic XYZColorxyz(double x, double y, double z) Create an XYZ color
-
Constructor Details
-
Color
public Color()
-
-
Method Details
-
toRGB
Convert the color to RGB- Returns:
- RGB representation of the color
-
toHSL
Convert the color to HSL- Returns:
- HSL representation of the color
-
toHSV
Convert the color to HSV- Returns:
- HSV representation of the color
-
toLAB
Convert the color to LAB- Returns:
- LAB representation of the color
-
toXYZ
Convert the color to XYZ- Returns:
- XYZ representation of the color
-
toHex
Get the hex representation of the color- Returns:
- Hex representation of the color (e.g. "#ff0000")
-
toAnsi
Get the ANSI representation of the color- Returns:
- ANSI representation of the color
-
toAnsiBackground
Get the ANSI representation of the color for the background- Returns:
- ANSI representation of the color for the background
-
toCssString
Get the CSS representation of the color- Returns:
- CSS representation of the color
-
fromHex
Get the color from a hex string- Parameters:
hex- Hex representation of the color (e.g. "#ff0000")- Returns:
- Color representation of the color
- Throws:
IllegalArgumentException- If the HEX code is invalid
-
rgb
Create an RGB color- Parameters:
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)- Returns:
- RGBColor instance
-
hsl
Create an HSL color- Parameters:
h- Hue component (0-360)s- Saturation component (0-1)l- Lightness component (0-1)- Returns:
- HSLColor instance
-
hsv
Create an HSV color- Parameters:
h- Hue component (0-360)s- Saturation component (0-1)v- Value component (0-1)- Returns:
- HSVColor instance
-
lab
Create a LAB color- Parameters:
l- Lightness componenta- A componentb- B component- Returns:
- LABColor instance
-
xyz
Create an XYZ color- Parameters:
x- X componenty- Y componentz- Z component- Returns:
- XYZColor instance
-