Package com.inet.lib.less
Class ColorUtils
- java.lang.Object
-
- com.inet.lib.less.ColorUtils
-
public class ColorUtils extends java.lang.ObjectSome methods for calculating colors.
-
-
Constructor Summary
Constructors Constructor Description ColorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublealpha(double color)Get the alpha value from a color valuestatic intargb(double color)Convert an color value as long into integer color valuestatic intblue(double color)Get the blue value from a color valuestatic doublegetColor(Expression param, CssFormatter formatter)Get the color value of the expression or fire an exception if not a color.static intgreen(double color)Get the green value from a color valuestatic doublehsla(HSL hsl)Create a color value.static intred(double color)Get the red value from a color valuestatic doublergb(int r, int g, int b)Create an color value.static doublergba(double r, double g, double b, double a)Create a color from rgba valuesstatic doublergba(int r, int g, int b, double a)Create an color value.static HSLtoHSL(double color)Create a HSL color.
-
-
-
Method Detail
-
toHSL
public static HSL toHSL(double color)
Create a HSL color.- Parameters:
color- argb color- Returns:
- the HSL
-
getColor
public static double getColor(Expression param, CssFormatter formatter) throws LessException
Get the color value of the expression or fire an exception if not a color.- Parameters:
param- the expression to evaluateformatter- current formatter- Returns:
- the color value of the expression
- Throws:
LessException- if the expression is not a color value
-
rgba
public static double rgba(double r, double g, double b, double a)Create a color from rgba values- Parameters:
r- red in range of 0 to 255.0g- green in range of 0 to 255.0b- blue in range of 0 to 255.0a- alpha in range of 0.0 to 1.0- Returns:
- color value as long
-
rgba
public static double rgba(int r, int g, int b, double a)Create an color value.- Parameters:
r- red in range from 0 to 255g- green in range from 0 to 255b- blue in range from 0 to 255a- alpha in range from 0.0 to 1.0- Returns:
- color value as long
-
rgb
public static double rgb(int r, int g, int b)Create an color value.- Parameters:
r- red in range from 0 to 255g- green in range from 0 to 255b- blue in range from 0 to 255- Returns:
- color value as long
-
argb
public static int argb(double color)
Convert an color value as long into integer color value- Parameters:
color- color value as long- Returns:
- color value as int
-
alpha
public static double alpha(double color)
Get the alpha value from a color value- Parameters:
color- color value as long- Returns:
- the alpha in the range 0.0 to 1.0
-
red
public static int red(double color)
Get the red value from a color value- Parameters:
color- color value as long- Returns:
- the alpha in the range 0 to 255
-
green
public static int green(double color)
Get the green value from a color value- Parameters:
color- color value as long- Returns:
- the alpha in the range 0 to 255
-
blue
public static int blue(double color)
Get the blue value from a color value- Parameters:
color- color value as long- Returns:
- the alpha in the range 0 to 255
-
hsla
public static double hsla(HSL hsl)
Create a color value.- Parameters:
hsl- a HSL value- Returns:
- a color as long
-
-