Class Color
java.lang.Object
zombie.core.Color
- All Implemented Interfaces:
Serializable
A simple wrapper round the values required for a colour
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloat
The alpha component of the colourfloat
The blue component of the colourstatic final Color
The fixed colour blackstatic final Color
The fixed colour bluestatic final Color
The fixed colour cyanstatic final Color
The fixed colour dark graystatic final Color
The fixed colour dark greenfloat
The green component of the colourstatic final Color
The fixed colour graystatic final Color
The fixed colour greenstatic final Color
The fixed colour light graystatic final Color
The fixed colour light greenstatic final Color
The fixed colour dark magentastatic final Color
The fixed colour dark orangestatic final Color
The fixed colour dark pinkstatic final Color
The fixed colour purplefloat
The red component of the colourstatic final Color
The fixed colour redstatic final Color
The fixed color transparentstatic final Color
The fixed colour whitestatic final Color
The fixed colour yellow -
Constructor Summary
ConstructorsConstructorDescriptionColor()
Color
(float _r, float _g, float _b) Create a 3 component colourColor
(float _r, float _g, float _b, float _a) Create a 4 component colourColor
(int value) Create a colour from an evil integer packed 0xAARRGGBB.Color
(int _r, int _g, int _b) Create a 3 component colourColor
(int _r, int _g, int _b, int _a) Create a 4 component colourCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic Color
abgrToColor
(int valueABGR, Color out_result) void
Add another colour to this oneAdd another colour to this onestatic int
blendABGR
(int valueABGR, int targetABGR) static int
blendBGR
(int valueABGR, int targetABGR) brighter()
Make a brighter instance of this colourbrighter
(float scale) Make a brighter instance of this colourvoid
changeHSBValue
(float hFactor, float sFactor, float bFactor) static int
colorToABGR
(float _r, float _g, float _b, float _a) static int
colorToABGR
(Color val) darker()
Make a darker instance of this colourdarker
(float scale) Make a darker instance of this colourstatic Color
Decode a number in a string and process it as a colour reference.boolean
void
fromColor
(int valueABGR) Deprecated.int
getAlpha()
get the alpha byte component of this colourint
get the alpha byte component of this colourstatic float
getAlphaChannelFromABGR
(int valueABGR) float
float
getB()
int
getBlue()
get the blue byte component of this colourint
get the blue byte component of this colourstatic float
getBlueChannelFromABGR
(int valueABGR) float
float
getG()
int
getGreen()
get the green byte component of this colourint
get the green byte component of this colourstatic float
getGreenChannelFromABGR
(int valueABGR) float
float
getR()
int
getRed()
get the red byte component of this colourint
get the red byte component of this colourstatic float
getRedChannelFromABGR
(int valueABGR) float
int
hashCode()
static Color
HSBtoRGB
(float hue, float saturation, float brightness) static Color
void
static int
lerpABGR
(int colA, int colB, float alpha) void
load
(ByteBuffer byteBuffer, int var2) void
loadCompact
(ByteBuffer byteBuffer) void
loadCompactNoAlpha
(ByteBuffer byteBuffer) Multiply this color by anotherstatic int
multiplyABGR
(int valueABGR, int multiplierABGR) static int
multiplyBGR
(int valueABGR, int multiplierABGR) static Color
random()
Create a random color.void
save
(ByteBuffer byteBuffer) void
saveCompact
(ByteBuffer byteBuffer) void
saveCompactNoAlpha
(ByteBuffer byteBuffer) scale
(float value) Scale the components of the colour by the given valuescaleCopy
(float value) Scale the components of the colour by the given valueset
(float _r, float _g, float _b) set
(float _r, float _g, float _b, float _a) void
setABGR
(int valueABGR) static int
setAlphaChannelToABGR
(int valueABGR, float _a) static int
setBlueChannelToABGR
(int valueABGR, float _b) void
static int
setGreenChannelToABGR
(int valueABGR, float _g) static int
setRedChannelToABGR
(int valueABGR, float _r) static int
tintABGR
(int targetABGR, int tintABGR) toString()
-
Field Details
-
transparent
The fixed color transparent -
white
The fixed colour white -
yellow
The fixed colour yellow -
red
The fixed colour red -
purple
The fixed colour purple -
blue
The fixed colour blue -
green
The fixed colour green -
black
The fixed colour black -
gray
The fixed colour gray -
cyan
The fixed colour cyan -
darkGray
The fixed colour dark gray -
lightGray
The fixed colour light gray -
pink
The fixed colour dark pink -
orange
The fixed colour dark orange -
magenta
The fixed colour dark magenta -
darkGreen
The fixed colour dark green -
lightGreen
The fixed colour light green -
a
public float aThe alpha component of the colour -
b
public float bThe blue component of the colour -
g
public float gThe green component of the colour -
r
public float rThe red component of the colour
-
-
Constructor Details
-
Color
public Color() -
Color
Copy constructor- Parameters:
color
- The color to copy into the new instance
-
Color
public Color(float _r, float _g, float _b) Create a 3 component colour- Parameters:
_r
- The red component of the colour (0.0_g
- The green component of the colour (0.0_b
- The blue component of the colour (0.0
-
Color
public Color(float _r, float _g, float _b, float _a) Create a 4 component colour- Parameters:
_r
- The red component of the colour (0.0_g
- The green component of the colour (0.0_b
- The blue component of the colour (0.0_a
- The alpha component of the colour (0.0
-
Color
-
Color
public Color(int _r, int _g, int _b) Create a 3 component colour- Parameters:
_r
- The red component of the colour (0_g
- The green component of the colour (0_b
- The blue component of the colour (0
-
Color
public Color(int _r, int _g, int _b, int _a) Create a 4 component colour- Parameters:
_r
- The red component of the colour (0_g
- The green component of the colour (0_b
- The blue component of the colour (0_a
- The alpha component of the colour (0
-
Color
public Color(int value) Create a colour from an evil integer packed 0xAARRGGBB. If AA is specified as zero then it will be interpreted as unspecified and hence a value of 255 will be recorded.- Parameters:
value
- The value to interpret for the colour
-
-
Method Details
-
getR
public float getR() -
getG
public float getG() -
getB
public float getB() -
setColor
-
fromColor
Deprecated.Converts the supplied binary value into color values, and sets the result to this object. Performs a clamp on the alpha channel. Performs a special-case on the alpha channel, where if it is 0, it is set to MAX instead. -
setABGR
public void setABGR(int valueABGR) -
abgrToColor
-
colorToABGR
-
colorToABGR
public static int colorToABGR(float _r, float _g, float _b, float _a) -
multiplyABGR
public static int multiplyABGR(int valueABGR, int multiplierABGR) -
multiplyBGR
public static int multiplyBGR(int valueABGR, int multiplierABGR) -
blendBGR
public static int blendBGR(int valueABGR, int targetABGR) -
blendABGR
public static int blendABGR(int valueABGR, int targetABGR) -
tintABGR
public static int tintABGR(int targetABGR, int tintABGR) -
lerpABGR
public static int lerpABGR(int colA, int colB, float alpha) -
getAlphaChannelFromABGR
public static float getAlphaChannelFromABGR(int valueABGR) -
getBlueChannelFromABGR
public static float getBlueChannelFromABGR(int valueABGR) -
getGreenChannelFromABGR
public static float getGreenChannelFromABGR(int valueABGR) -
getRedChannelFromABGR
public static float getRedChannelFromABGR(int valueABGR) -
setAlphaChannelToABGR
public static int setAlphaChannelToABGR(int valueABGR, float _a) -
setBlueChannelToABGR
public static int setBlueChannelToABGR(int valueABGR, float _b) -
setGreenChannelToABGR
public static int setGreenChannelToABGR(int valueABGR, float _g) -
setRedChannelToABGR
public static int setRedChannelToABGR(int valueABGR, float _r) -
random
Create a random color. -
decode
-
add
-
addToCopy
-
brighter
Make a brighter instance of this colour- Returns:
- The brighter version of this colour
-
brighter
Make a brighter instance of this colour- Parameters:
scale
- The scale up of RGB (i.e. if you supply 0.03 the colour will be brightened by 3%)- Returns:
- The brighter version of this colour
-
darker
Make a darker instance of this colour- Returns:
- The darker version of this colour
-
darker
Make a darker instance of this colour- Parameters:
scale
- The scale down of RGB (i.e. if you supply 0.03 the colour will be darkened by 3%)- Returns:
- The darker version of this colour
-
equals
-
set
-
set
-
set
-
save
-
load
-
getAlpha
public int getAlpha()get the alpha byte component of this colour- Returns:
- The alpha component (range 0-255)
-
getAlphaFloat
public float getAlphaFloat() -
getRedFloat
public float getRedFloat() -
getGreenFloat
public float getGreenFloat() -
getBlueFloat
public float getBlueFloat() -
getAlphaByte
public int getAlphaByte()get the alpha byte component of this colour- Returns:
- The alpha component (range 0-255)
-
getBlue
public int getBlue()get the blue byte component of this colour- Returns:
- The blue component (range 0-255)
-
getBlueByte
public int getBlueByte()get the blue byte component of this colour- Returns:
- The blue component (range 0-255)
-
getGreen
public int getGreen()get the green byte component of this colour- Returns:
- The green component (range 0-255)
-
getGreenByte
public int getGreenByte()get the green byte component of this colour- Returns:
- The green component (range 0-255)
-
getRed
public int getRed()get the red byte component of this colour- Returns:
- The red component (range 0-255)
-
getRedByte
public int getRedByte()get the red byte component of this colour- Returns:
- The red component (range 0-255)
-
hashCode
-
multiply
-
scale
Scale the components of the colour by the given value- Parameters:
value
- The value to scale by
-
scaleCopy
Scale the components of the colour by the given value- Parameters:
value
- The value to scale by- Returns:
- The copy which has been scaled
-
toString
-
interp
-
changeHSBValue
public void changeHSBValue(float hFactor, float sFactor, float bFactor) -
HSBtoRGB
-
HSBtoRGB
-
saveCompactNoAlpha
- Throws:
IOException
-
loadCompactNoAlpha
- Throws:
IOException
-
saveCompact
- Throws:
IOException
-
loadCompact
- Throws:
IOException
-