Class Color

java.lang.Object
org.spongepowered.api.util.Color
All Implemented Interfaces:
RGBLike, DataSerializable

public final class Color extends Object implements DataSerializable, RGBLike
  • Field Details

    • 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
    • PINK

      public static final Color PINK
  • Method Details

    • ofRgb

      public static Color ofRgb(int hex)
      Gets a new Color based on the hexadecimal value for a combined red, green, and blue 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 new Color based on the hexadecimal value for a combined red, green, and blue color. Note that colors do not utilize an alpha modifier
      Parameters:
      red - The red value
      green - The green value
      blue - The blue value
      Returns:
      The color object
    • of

      public static Color of(Color color)
      Converts the provided Color object into a valid Color object to be used throughout the API.
      Parameters:
      color - The java color object
      Returns:
      The converted color object
    • of

      public static Color of(Vector3i vector3i)
      Converts the provided Vector3i into a Color object.
      Parameters:
      vector3i - The vector of three integers representing color
      Returns:
      The color object
    • of

      public static Color of(Vector3f vector3f)
      converts the provided Vector3f into a Color object.
      Parameters:
      vector3f - The vector of three floats representing color
      Returns:
      The color object
    • of

      public static Color of(Vector3d vector3d)
      converts the provided Vector3d into a Color object.
      Parameters:
      vector3d - The vector of three doubles representing color
      Returns:
      The color object
    • mixDyeColors

      public static Color mixDyeColors(DyeColor... colors)
      Creates a new Color combining the provided DyeColor objects. Since DyeColors can be converted into Color 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 new Color combining the provided Color 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 the red value of this Color.
      Specified by:
      red in interface RGBLike
      Returns:
      The red value
    • withRed

      public Color withRed(int red)
      Creates a new Color by using the provided red color, while retaining the current green() and blue() 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 the red value of this Color.
      Specified by:
      green in interface RGBLike
      Returns:
      The red value
    • withGreen

      public Color withGreen(int green)
      Creates a new Color by using the provided green color, while retaining the current red() and blue() 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 current blue value of this Color.
      Specified by:
      blue in interface RGBLike
      Returns:
      The blue value
    • withBlue

      public Color withBlue(int blue)
      Creates a new Color by using the provided blue color, while retaining the current green() and red() values.
      Parameters:
      blue - The blue value to use
      Returns:
      The new color object
    • asJavaColor

      public Color asJavaColor()
      Converts this Color into a Color object for use in other APIs.
      Returns:
      The java awt color object
    • rgb

      public int rgb()
      Gets the red 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 provided Colors.
      Parameters:
      colors - The provided colors to mix
      Returns:
      The new color
    • mixWithDyes

      public Color mixWithDyes(DyeColor... dyeColors)
      Similar to mixWithColors(Color...), mixes the provided DyeColors with this Color.
      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 this DataSerializable. The version may differ between instances of plugins and implementations such that the DataView from DataSerializable.toContainer() may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand with DataContentUpdater as it is required when there exists any DataView of this DataSerializable with an "older" version.
      Specified by:
      contentVersion in interface DataSerializable
      Returns:
      The version of the content being serialized
    • toContainer

      public DataContainer toContainer()
      Description copied from interface: DataSerializable
      Serializes this object into a comprehensible DataContainer.
      Specified by:
      toContainer in interface DataSerializable
      Returns:
      A newly created DataContainer
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object