Class Color
java.lang.Object
io.github.xrickastley.sevenelements.util.Color
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double factor) Addsfactorto thisColor.add(double r, double g, double b) Adds all the values of thisColorby their respective factors.add(double r, double g, double b, double a) Adds all the values of thisColorby their respective factors.intasARGB()asHex()intasRGB()from()Creates a newColorbased on the values of this color.static ColorfromARGBHex(int argbHex) static ColorfromRGBAHex(String rgbaHex) Turns an RGBA hex string#rrggbbaato aColorobject.floatgetAlpha()intGets thealphavalue as a number.intgetBlue()floatGets thebluevalue as a percent.intgetGreen()floatGets thegreenvalue as a percent.intgetRed()floatGets theredvalue as a percent.static ColorgradientStep(Color start, Color end, double step) static ColorgradientStep(Color start, Color end, double step, Ease ease) multiply(double factor) Creates a new color based on thisColormultiplied byfactor.multiply(double r, double g, double b) Creates a new color based on thisColormultiplied by their respective factors.multiply(double r, double g, double b, double a) Creates a new color based on thisColormultiplied by their respective factors.toString()
-
Field Details
-
red
private final int red -
green
private final int green -
blue
private final int blue -
alpha
private final float alpha
-
-
Constructor Details
-
Color
public Color(int red, int green, int blue) -
Color
public Color(int red, int green, int blue, float alpha) -
Color
private Color(double red, double green, double blue, double alpha)
-
-
Method Details
-
getRed
public int getRed() -
getGreen
public int getGreen() -
getBlue
public int getBlue() -
getAlpha
public float getAlpha() -
getRedAsPercent
public float getRedAsPercent()Gets theredvalue as a percent.- Returns:
- The
redvalue as a percent from0to255, defined asred / 255.
-
getGreenAsPercent
public float getGreenAsPercent()Gets thegreenvalue as a percent.- Returns:
- The
redvalue as a percent from0to255, defined asblue / 255.
-
getBlueAsPercent
public float getBlueAsPercent()Gets thebluevalue as a percent.- Returns:
- The
bluevalue as a percent from0to255, defined asblue / 255.
-
getAlphaAsRange
public int getAlphaAsRange()Gets thealphavalue as a number.- Returns:
- The
alphavalue as a number in the range0to255, defined asalpha * 255.
-
asHex
-
asRGB
public int asRGB() -
asARGB
public int asARGB() -
from
Creates a newColorbased on the values of this color.- Returns:
- The new
Color
-
add
Addsfactorto thisColor.- Parameters:
factor- The factor to add to this color.- Returns:
- This
Colorobject.
-
add
Adds all the values of thisColorby their respective factors.- Parameters:
r- The factor to add to the red value.g- The factor to add to the green value.b- The factor to add to the blue value.- Returns:
- This
Colorobject.
-
add
Adds all the values of thisColorby their respective factors.- Parameters:
r- The factor to add to the red value.g- The factor to add to the green value.b- The factor to add to the blue value.a- The factor to add to the alpha value.- Returns:
- This
Colorobject.
-
multiply
Creates a new color based on thisColormultiplied byfactor.- Parameters:
factor- The factor to multiply this color with.- Returns:
- The resulting
Colorobject.
-
multiply
Creates a new color based on thisColormultiplied by their respective factors.- Parameters:
r- The factor to multiply the red value with.g- The factor to multiply the green value with.b- The factor to multiply the blue value with.- Returns:
- The resulting
Colorobject.
-
multiply
Creates a new color based on thisColormultiplied by their respective factors.- Parameters:
r- The factor to multiply the red value with.g- The factor to multiply the green value with.b- The factor to multiply the blue value with.a- The factor to multiply the alpha value with.- Returns:
- The resulting
Colorobject.
-
toString
-
fromRGBAHex
Turns an RGBA hex string#rrggbbaato aColorobject. This method also permits RGB hex strings#rrggbband will use1as the value for thealpha.- Parameters:
rgbaHex- An RGBA hex string#rrggbbaaor an RGB hex string#rrggbb- Returns:
- A
Colorobject created from the provided hex string.
-
fromARGBHex
-
gradient
-
gradient
-
gradientStep
-
gradientStep
-