Class AlphaColor

java.lang.Object
net.minestom.server.color.Color
net.minestom.server.color.AlphaColor
All Implemented Interfaces:
ARGBLike, RGBLike

public final class AlphaColor extends Color implements ARGBLike
A general purpose class for representing colors.

Colors must be in the range of 0-255.

  • Field Details

  • Constructor Details

    • AlphaColor

      public AlphaColor(float alpha, float red, float green, float blue)
    • AlphaColor

      public AlphaColor(int alpha, int red, int green, int blue)
    • AlphaColor

      public AlphaColor(int argb)
      Creates an alpha color from an integer. This is done by reading each color component from the lowest order 32 bits of the integer, and creating a color from those components.
      Parameters:
      argb - the integer
    • AlphaColor

      public AlphaColor(int alpha, RGBLike rgbLike)
      Creates a color from an RGB-like color.
      Parameters:
      rgbLike - the color
  • Method Details

    • fromARGBLike

      public static AlphaColor fromARGBLike(ARGBLike argbLike)
    • withRed

      public AlphaColor withRed(int red)
      Overrides:
      withRed in class Color
    • withGreen

      public AlphaColor withGreen(int green)
      Overrides:
      withGreen in class Color
    • withBlue

      public AlphaColor withBlue(int blue)
      Overrides:
      withBlue in class Color
    • withAlpha

      public AlphaColor withAlpha(int alpha)
      Overrides:
      withAlpha in class Color
    • asARGB

      public int asARGB()
      Gets the color as an ARGB integer.
      Returns:
      An integer representation of this color, as 0xAARRGGBB
    • asRGBA

      public int asRGBA()
      Gets the color as an RGBA integer.
      Returns:
      An integer representation of this color, as 0xRRGGBBAA
    • fromRGBAHexString

      @Nullable public static @Nullable AlphaColor fromRGBAHexString(@Pattern("#[0-9a-fA-F]{8}") String hexRGBA)
      Attempt to parse a color from a #-prefixed hex string.

      This string must be in the format #RRGGBBAA.

      Parameters:
      hexRGBA - the input value
      Returns:
      a color if possible, or null if any components are invalid
    • fromARGBHexString

      @Nullable public static @Nullable AlphaColor fromARGBHexString(@Pattern("#[0-9a-fA-F]{8}") String hexARGB)
      Attempt to parse a color from a #-prefixed hex string.

      This string must be in the format #AARRGGBB.

      Parameters:
      hexARGB - the input value
      Returns:
      a color if possible, or null if any components are invalid
    • alpha

      public int alpha()
      Specified by:
      alpha in interface ARGBLike
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Color
    • toString

      public String toString()
      Overrides:
      toString in class Color