Package org.spongepowered.api.util
Class Color
- java.lang.Object
-
- org.spongepowered.api.util.Color
-
- All Implemented Interfaces:
RGBLike
,DataSerializable
public final class Color extends Object implements DataSerializable, RGBLike
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Color.Builder
-
Field Summary
Fields Modifier and Type Field Description static Color
BLACK
static Color
BLUE
static Color
CYAN
static Color
DARK_CYAN
static Color
DARK_GREEN
static Color
DARK_MAGENTA
static Color
GRAY
static Color
GREEN
static Color
LIME
static Color
MAGENTA
static Color
NAVY
static Color
PINK
static Color
PURPLE
static Color
RED
static Color
WHITE
static Color
YELLOW
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Color
asJavaColor()
@org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int
blue()
Gets the currentblue
value of thisColor
.int
contentVersion()
Gets the content version of thisDataSerializable
.boolean
equals(Object obj)
@org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int
green()
Gets thered
value of thisColor
.int
hashCode()
static Color
mixColors(Color... colors)
static Color
mixDyeColors(DyeColor... colors)
Color
mixWithColors(Color... colors)
Creates a new color with the providedColors
.Color
mixWithDyes(DyeColor... dyeColors)
static Color
of(Color color)
static Color
of(Vector3d vector3d)
static Color
of(Vector3f vector3f)
static Color
of(Vector3i vector3i)
static Color
ofRgb(int hex)
static Color
ofRgb(int red, int green, int blue)
@org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int
red()
Gets thered
value of thisColor
.int
rgb()
Gets thered green blue
representation of this color in a "hexadecimal" format.DataContainer
toContainer()
Serializes this object into a comprehensibleDataContainer
.String
toString()
Color
withBlue(int blue)
Color
withGreen(int green)
Color
withRed(int red)
-
-
-
Field Detail
-
BLACK
public static final Color BLACK
-
GRAY
public static final Color GRAY
-
WHITE
public static final Color WHITE
-
BLUE
public static final Color BLUE
-
GREEN
public static final Color GREEN
-
LIME
public static final Color LIME
-
RED
public static final Color RED
-
YELLOW
public static final Color YELLOW
-
MAGENTA
public static final Color MAGENTA
-
PURPLE
public static final Color PURPLE
-
DARK_CYAN
public static final Color DARK_CYAN
-
DARK_GREEN
public static final Color DARK_GREEN
-
DARK_MAGENTA
public static final Color DARK_MAGENTA
-
CYAN
public static final Color CYAN
-
NAVY
public static final Color NAVY
-
PINK
public static final Color PINK
-
-
Method Detail
-
ofRgb
public static Color ofRgb(int hex)
Gets a newColor
based on the hexadecimal value for a combinedred
,green
, andblue
color. Note that colors do not utilize an alpha modifier- Parameters:
hex
- The hexadecimal value of the color- Returns:
- The color object
-
ofRgb
public static Color ofRgb(int red, int green, int blue)
Gets a newColor
based on the hexadecimal value for a combinedred
,green
, andblue
color. Note that colors do not utilize an alpha modifier- Parameters:
red
- The red valuegreen
- The green valueblue
- The blue value- Returns:
- The color object
-
of
public static Color of(Color color)
- Parameters:
color
- The java color object- Returns:
- The converted color object
-
of
public static Color of(Vector3i vector3i)
- Parameters:
vector3i
- The vector of three integers representing color- Returns:
- The color object
-
of
public static Color of(Vector3f vector3f)
- Parameters:
vector3f
- The vector of three floats representing color- Returns:
- The color object
-
of
public static Color of(Vector3d vector3d)
- Parameters:
vector3d
- The vector of three doubles representing color- Returns:
- The color object
-
mixDyeColors
public static Color mixDyeColors(DyeColor... colors)
Creates a newColor
combining the providedDyeColor
objects. SinceDyeColor
s can be converted intoColor
objects themselves, their summation and average is taken into effect to properly mix the colors together.- Parameters:
colors
- The colors to mix- Returns:
- The final output mixed color
-
mixColors
public static Color mixColors(Color... colors)
Creates a newColor
combining the providedColor
objects, their summation and average is taken into effect to properly mix the colors together.- Parameters:
colors
- The colors to mix- Returns:
- The final output mixed color
-
red
public @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int red()
Gets thered
value of thisColor
.
-
withRed
public Color withRed(int red)
Creates a newColor
by using the providedred
color, while retaining the currentgreen()
andblue()
values.- Parameters:
red
- The red value to use- Returns:
- The new color object
-
green
public @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int green()
Gets thered
value of thisColor
.
-
withGreen
public Color withGreen(int green)
Creates a newColor
by using the providedgreen
color, while retaining the currentred()
andblue()
values.- Parameters:
green
- The green value to use- Returns:
- The new color object
-
blue
public @org.checkerframework.common.value.qual.IntRange(from=0L, to=255L) int blue()
Gets the currentblue
value of thisColor
.
-
withBlue
public Color withBlue(int blue)
Creates a newColor
by using the providedblue
color, while retaining the currentgreen()
andred()
values.- Parameters:
blue
- The blue value to use- Returns:
- The new color object
-
asJavaColor
public Color asJavaColor()
- Returns:
- The java awt color object
-
rgb
public int rgb()
Gets thered green blue
representation of this color in a "hexadecimal" format.- Returns:
- The current color value in a hexadecimal format
-
mixWithColors
public Color mixWithColors(Color... colors)
Creates a new color with the providedColors
.- Parameters:
colors
- The provided colors to mix- Returns:
- The new color
-
mixWithDyes
public Color mixWithDyes(DyeColor... dyeColors)
- Parameters:
dyeColors
- The dye colors to mix- Returns:
- The new color
-
contentVersion
public int contentVersion()
Description copied from interface:DataSerializable
Gets the content version of thisDataSerializable
. The version may differ between instances of plugins and implementations such that theDataView
fromDataSerializable.toContainer()
may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand withDataContentUpdater
as it is required when there exists anyDataView
of thisDataSerializable
with an "older" version.- Specified by:
contentVersion
in interfaceDataSerializable
- Returns:
- The version of the content being serialized
-
toContainer
public DataContainer toContainer()
Description copied from interface:DataSerializable
Serializes this object into a comprehensibleDataContainer
.- Specified by:
toContainer
in interfaceDataSerializable
- Returns:
- A newly created DataContainer
-
-