Package dev.prozilla.pine.common.system
Class Color
java.lang.Object
dev.prozilla.pine.common.system.Color
- All Implemented Interfaces:
Cloneable<Color>
,Printable
,Transceivable<Color>
,Transmittable<Color>
- Direct Known Subclasses:
Colour
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
aqua()
static Color
black()
static Color
blue()
clone()
Returns a new object that is equal to this object.static Color
cyan()
static Color
darkBlue()
static Color
darkCyan()
static Color
darkGray()
static Color
static Color
static Color
static Color
darkRed()
static Color
Decodes aString
into aColor
.static Color
dimGray()
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
gold()
static Color
gray()
static Color
green()
static Color
hsl
(float hue, float saturation, float lightness) Source: HSL to RGB color conversionstatic Color
hsl
(int hue, int saturation, int lightness) static Color
static Color
static Color
static Color
static Color
static Color
lime()
static Color
magenta()
static Color
maroon()
static Color
static Color
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
navy()
static Color
olive()
static Color
orange()
static Color
static Color
Deprecated.static Color
pink()
static Color
purple()
static Color
static Color
red()
self()
set
(float red, float green, float blue, float alpha) set
(int red, int green, int blue, int alpha) 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) static Color
silver()
static Color
skyBlue()
static Color
static Color
teal()
toColour()
static Color
tomato()
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.void
Transmits this object's data to a given target object.static Color
static Color
static Color
violet()
static Color
white()
static Color
static Color
yellow()
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.prozilla.pine.common.Transceivable
receive
-
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
-
transmit
Description copied from interface:Transmittable
Transmits this object's data to a given target object.- Specified by:
transmit
in interfaceTransmittable<Color>
- Parameters:
target
- the target object to which data will be transmitted
-
setRGB
-
set
-
set
-
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.
-
toColour
-
self
- Specified by:
self
in interfaceTransceivable<Color>
-
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. -
hsl
-
hsl
Source: HSL to RGB color conversion -
decode
Decodes aString
into aColor
. Supports octal and hexadecimal number representations of opaque and transparent colors.- Parameters:
input
- String that represents a color as a 24-bit or 32-bit integer- Returns:
- Color
- Throws:
NumberFormatException
- If the string cannot be decoded.
-
parse
Deprecated.Replaced byColorParser
as of 1.2.0 -
white
-
black
-
red
-
green
-
blue
-
transparent
-
aqua
-
cyan
-
darkBlue
-
darkCyan
-
darkGray
-
darkGreen
-
darkMagenta
-
darkOrange
-
darkRed
-
dimGray
-
gold
-
gray
-
lightBlue
-
lightCyan
-
lightGray
-
lightGreen
-
lightYellow
-
lime
-
magenta
-
maroon
-
mediumBlue
-
mintCream
-
olive
-
orange
-
orangeRed
-
pink
-
purple
-
rebeccaPurple
-
silver
-
skyBlue
-
springGreen
-
teal
-
tomato
-
turquoise
-
violet
-
whiteSmoke
-
yellow
-
ColorParser
as of 1.2.0