Class ColorUtils
-
- All Implemented Interfaces:
public final class ColorUtils
-
-
Method Summary
Modifier and Type Method Description final IntegergetRed()final IntegergetGreen()final IntegergetBlue()final IntegergetAlpha()final static PolyColorrgba(Integer r, Integer g, Integer b, Float a)create a color from the given red, green, and blue integer values, and an alpha value 0f..1ffinal static PolyColorrgba(Integer r, Integer g, Integer b)create a color from the given red, green, and blue integer values, and an alpha value 0f..1ffinal static PolyColor.Statichsba(Float h, Float s, Float b, Float a)final static PolyColorhex(String hex)final static PolyColortoColor(Integer $self)Takes an ARGB integer color and returns a PolyColor object. final static PolyColortoColor(String $self)Turn the given hex string into a color. final static PolyColortoColor(String $self, Float alpha)final static PolyColor.Gradient.AnimatedanimatableGradient(PolyColor.Gradient $self)final static PolyColor.Animatedanimatable(PolyColor $self)final static PolyColor.Mutablemutable(PolyColor $self)final static StringtoHex(PolyColor $self, Boolean alpha, Boolean hash)final static PolyColortoPolyColor(Color $self)Return a PolyUI compatible color object representative of this Java color object. final static ColortoJavaColor(PolyColor $self)Return a static java Color object of this color at the instant this method is called. final static IntegerHSBtoRGB(Float hue, Float saturation, Float brightness, Float alpha)Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model. final static FloatArrayRGBtoHSB(Integer r, Integer g, Integer b, FloatArray out)Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model. -
-
Method Detail
-
rgba
final static PolyColor rgba(Integer r, Integer g, Integer b, Float a)
create a color from the given red, green, and blue integer values, and an alpha value
0f..1f
-
rgba
final static PolyColor rgba(Integer r, Integer g, Integer b)
create a color from the given red, green, and blue integer values, and an alpha value
0f..1f
-
toColor
final static PolyColor toColor(Integer $self)
Takes an ARGB integer color and returns a PolyColor object.
-
toColor
final static PolyColor toColor(String $self)
Turn the given hex string into a color.
If it is 8 characters long, it is assumed to be in the format
#RRGGBBAA(alpha optional)If there is a leading
#, it will be removed.If it is 1 character long, the character is repeated e.g.
#f->#ffffffIf it is 2 characters long, the character is repeated e.g.
#0f->#0f0f0fIf it is 3 characters long, the character is repeated e.g.
#0fe->#00ffee
-
animatableGradient
final static PolyColor.Gradient.Animated animatableGradient(PolyColor.Gradient $self)
-
animatable
final static PolyColor.Animated animatable(PolyColor $self)
-
mutable
final static PolyColor.Mutable mutable(PolyColor $self)
-
toPolyColor
final static PolyColor toPolyColor(Color $self)
Return a PolyUI compatible color object representative of this Java color object.
- Since:
1.1.51
-
toJavaColor
final static Color toJavaColor(PolyColor $self)
Return a static java Color object of this color at the instant this method is called.
Future changes to this color will not be reflected in the returned object.
- Since:
1.1.51
-
HSBtoRGB
final static Integer HSBtoRGB(Float hue, Float saturation, Float brightness, Float alpha)
Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.
The
saturationandbrightnesscomponents should be floating-point values between zero and one (numbers in the range 0.0-1.0). Thehuecomponent can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.The integer that is returned by HSBtoRGB encodes the value of a color in bits 0-23 of an integer value that is the same format used by the method getARGB(). This integer can be supplied as an argument to the toColor method that takes a single integer argument to create a PolyColor.
- Parameters:
hue- the hue component of the colorsaturation- the saturation of the colorbrightness- the brightness of the coloralpha- (since 1.- Returns:
the RGB value of the color with the indicated hue, saturation, and brightness.
-
RGBtoHSB
final static FloatArray RGBtoHSB(Integer r, Integer g, Integer b, FloatArray out)
Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.
If the out argument is
null, then a new array is allocated to return the result. Otherwise, the method returns the array out, with the values put into that array.- Parameters:
r- the red component of the colorg- the green component of the colorb- the blue component of the colorout- the array used to return the three HSB values, ornull- Returns:
an array of three elements containing the hue, saturation, and brightness (in that order), of the color with the indicated red, green, and blue components.
- Since:
0.18.2
-
-
-
-