Class Color
java.lang.Object
dev.prozilla.pine.common.system.resource.Color
Represents an RGBA color.
-
Constructor Summary
ConstructorsConstructorDescriptionColor()
The default color is black.Color
(float red, float green, float blue) Creates an RGB-Color with an alpha value of 1.Color
(float red, float green, float blue, float alpha) Creates an RGBA-Color.Color
(int red, int green, int blue) Creates an RGB-Color with an alpha value of 1.Color
(int red, int green, int blue, int alpha) Creates an RGBA-Color.Creates an RGB-Color from a java.awt.Color instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic Color
black()
static Color
blue()
clone()
Returns a new object that is equal to this object.static Color
Decodes aString
into aColor
.boolean
Checks if two colors are equal.boolean
float
getAlpha()
Returns the transparency.float
getBlue()
Returns the blue component.float
getGreen()
Returns the green component.float
getRed()
Returns the red component.static Color
green()
Mixes half of this color with half of another color.Mixes this color with another color based on a factor.multiply
(float scalar) static Color
red()
setAlpha
(float alpha) Sets the transparency.setAlpha
(int alpha) Sets the transparency.setBlue
(float blue) Sets the blue component.setBlue
(int blue) Sets the blue component.setGreen
(float green) Sets the green component.setGreen
(int green) Sets the green component.setRed
(float red) Sets the red component.setRed
(int red) Sets the red component.setRGB
(float red, float green, float blue) setRGB
(int red, int green, int blue) toString()
Returns a string representation of this object.Returns the color as a (x,y,z)-Vector.Returns the color as a (x,y,z,w)-Vector.static Color
white()
-
Constructor Details
-
Color
public Color()The default color is black. -
Color
Creates an RGB-Color from a java.awt.Color instance.- Parameters:
color
- Color instance
-
Color
public Color(float red, float green, float blue) Creates an RGB-Color with an alpha value of 1.- Parameters:
red
- The red component. Range from 0f to 1f.green
- The green component. Range from 0f to 1f.blue
- The blue component. Range from 0f to 1f.
-
Color
public Color(float red, float green, float blue, float alpha) Creates an RGBA-Color.- Parameters:
red
- The red component. Range from 0f to 1f.green
- The green component. Range from 0f to 1f.blue
- The blue component. Range from 0f to 1f.alpha
- The transparency. Range from 0f to 1f.
-
Color
public Color(int red, int green, int blue) Creates an RGB-Color with an alpha value of 1.- Parameters:
red
- The red component. Range from 0 to 255.green
- The green component. Range from 0 to 255.blue
- The blue component. Range from 0 to 255.
-
Color
public Color(int red, int green, int blue, int alpha) Creates an RGBA-Color.- Parameters:
red
- The red component. Range from 0 to 255.green
- The green component. Range from 0 to 255.blue
- The blue component. Range from 0 to 255.alpha
- The transparency. Range from 0 to 255.
-
-
Method Details
-
copyRGB
-
setRGB
-
setRGB
-
getRed
public float getRed()Returns the red component. Range from 0f to 1f.- Returns:
- The red component.
-
setRed
Sets the red component.- Parameters:
red
- The red component. Range from 0f to 1f.
-
setRed
Sets the red component.- Parameters:
red
- The red component. Range from 0 to 255.
-
getGreen
public float getGreen()Returns the green component. Range from 0f to 1f.- Returns:
- The green component.
-
setGreen
Sets the green component.- Parameters:
green
- The green component. Range from 0f to 1f.
-
setGreen
Sets the green component.- Parameters:
green
- The green component. Range from 0 to 255.
-
getBlue
public float getBlue()Returns the blue component. Range from 0f to 1f.- Returns:
- The blue component.
-
setBlue
Sets the blue component.- Parameters:
blue
- The blue component. Range from 0f to 1f.
-
setBlue
Sets the blue component.- Parameters:
blue
- The blue component. Range from 0 to 255.
-
getAlpha
public float getAlpha()Returns the transparency. Range from 0f to 1f.- Returns:
- The transparency.
-
setAlpha
Sets the transparency.- Parameters:
alpha
- The transparency. Range from 0f to 1f.
-
setAlpha
Sets the transparency.- Parameters:
alpha
- The transparency. Range from 0 to 255.
-
multiply
-
mix
Mixes half of this color with half of another color.- Parameters:
color
- Color to mix with this color
-
mix
Mixes this color with another color based on a factor.- Parameters:
color
- Color to mix with this colorfactor
- Mixing factor, Range from 0f to 1f.
-
toVector3f
Returns the color as a (x,y,z)-Vector.- Returns:
- The color as vec3.
-
toVector4f
Returns the color as a (x,y,z,w)-Vector.- Returns:
- The color as vec4.
-
equals
-
equals
Checks if two colors are equal. Two colors are equal if they share the same R, G, B and A values. -
clone
Description copied from interface:Cloneable
Returns a new object that is equal to this object. -
toString
Description copied from interface:Printable
Returns a string representation of this object. -
white
-
black
-
red
-
green
-
blue
-
decode
Decodes aString
into aColor
. Supports octal and hexadecimal number representations of opaque colors.- Parameters:
nm
- String that represents a color as a 24-bit integer- Returns:
- Color
- Throws:
NumberFormatException
- If the string cannot be decoded.
-