Package com.xebisco.yield
Class Color
java.lang.Object
com.xebisco.yield.Color
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ImmutableColor
This class represents a color with
RGB or ARGB format. Storing red, green, blue and alpha values with double floating point precision.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThis enumeration is used to specify the format of the color value when creating a new `Color` object. -
Constructor Summary
ConstructorsConstructorDescriptionColor(double red, double green, double blue) Constructor that takes red, green, and blue values.Color(double red, double green, double blue, double alpha) Constructor that takes red, green, blue, and alpha values.Color(int rgb, double alpha) Constructor that takes an RGB value and an alpha value.Color(long color) Constructor that takes a long value representing a color.Color(long color, Color.Format format) Constructor that takes a long value representing a color and a format.Constructor that takes another Color object and creates a copy of it. -
Method Summary
Modifier and TypeMethodDescriptiondoublealpha()Getter of the alpha value of this Color.intargb()The function returns an integer value representing the ARGB color code based on the alpha, red, green, and blue values.doubleblue()Getter of the blue value of this Color.brighter()Returns a new Color object that is a lighter version of this Color object.brighter(double value) Returns a new color with the same hue and saturation, but with a brighter value.clone()darker()Returns a new Color object that is a darker version of this Color object.darker(double value) If the color is already black, return black.booleandoublegreen()Getter of the green value of this Color.inthashCode()invert()Invert the color by subtracting each component from 1.doublered()Getter of the red value of this Color.intrgb()The function returns an integer representation of the RGB color values by converting the red, green, and blue values to their corresponding 8-bit values and combining them.intrgba()The function returns an integer value representing the RGBA color code based on the given red, green, blue, and alpha values.setAlpha(double alpha) Setter of the alpha value of this Color.setBlue(double blue) Setter of the blue value of this Color.setGreen(double green) Setter of the green value of this Color.setRed(double red) Setter of the red value of this Color.toString()
-
Constructor Details
-
Color
public Color(long color) Constructor that takes a long value representing a color.- Parameters:
color- The long value representing the color.
-
Color
Constructor that takes a long value representing a color and a format.- Parameters:
color- The long value representing the color.format- The format of the color value.
-
Color
Constructor that takes another Color object and creates a copy of it.- Parameters:
toCopy- The Color object to copy.
-
Color
public Color(int rgb, double alpha) Constructor that takes an RGB value and an alpha value.- Parameters:
rgb- The RGB value.alpha- The alpha value.
-
Color
public Color(double red, double green, double blue) Constructor that takes red, green, and blue values.- Parameters:
red- The red value.green- The green value.blue- The blue value.
-
Color
public Color(double red, double green, double blue, double alpha) Constructor that takes red, green, blue, and alpha values.- Parameters:
red- The red value.green- The green value.blue- The blue value.alpha- The alpha value.
-
-
Method Details
-
invert
Invert the color by subtracting each component from 1.- Returns:
- A new Color object with the inverted values of the original Color object.
-
brighter
Returns a new color with the same hue and saturation, but with a brighter value.- Parameters:
value- The amount to brighten the color by.- Returns:
- A new color with the same alpha value but with the red, green, and blue values increased by the value parameter.
-
darker
If the color is already black, return black.- Parameters:
value- The amount to brighten or darken the color.- Returns:
- A new Color object with the same RGB values as the original, but with the brightness adjusted by the value.
-
darker
Returns a new Color object that is a darker version of this Color object.- Returns:
- A new Color object with the same RGB values as the original, but with the brightness reduced by 20%.
-
brighter
Returns a new Color object that is a lighter version of this Color object.- Returns:
- A new Color object with the same RGB values as the original, but with the brightness increased by 20%.
-
red
public double red()Getter of the red value of this Color.- Returns:
- The 'red' variable.
-
setRed
Setter of the red value of this Color. -
green
public double green()Getter of the green value of this Color.- Returns:
- The 'green' variable.
-
setGreen
Setter of the green value of this Color. -
blue
public double blue()Getter of the blue value of this Color.- Returns:
- The 'blue' variable.
-
setBlue
Setter of the blue value of this Color. -
alpha
public double alpha()Getter of the alpha value of this Color.- Returns:
- The 'alpha' variable.
-
setAlpha
Setter of the alpha value of this Color. -
rgb
public int rgb()The function returns an integer representation of the RGB color values by converting the red, green, and blue values to their corresponding 8-bit values and combining them.- Returns:
- The method is returning an integer value that represents the RGB color of the object. The RGB value is calculated by multiplying the red, green, and blue values by 255 and then shifting them to the appropriate positions in the integer value.
-
argb
public int argb()The function returns an integer value representing the ARGB color code based on the alpha, red, green, and blue values.- Returns:
- The method is returning an integer value that represents the ARGB (Alpha, Red, Green, Blue) color code of the color object.
-
rgba
public int rgba()The function returns an integer value representing the RGBA color code based on the given red, green, blue, and alpha values.- Returns:
- The method is returning an integer value that represents the RGBA color value of the object. The value is obtained by shifting the red, green, blue, and alpha values to their respective positions in the 8-bit integer and then combining them using bitwise operations.
-
equals
-
hashCode
public int hashCode() -
toString
-
clone
-