Interface Color


public sealed interface Color
ARGB Color
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    8 bit, color channel mask
    static final int
    Maximum color value
    static final int
    Minimum color value
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the ARGB value of this color.
    static Color
    argb(int argb)
    Creates a color from the specified argb value.
    static Color
    argb(int alpha, int red, int green, int blue)
    Creates a color object from the specified rgb components
    @NotNull Color
    blendHsv(@Range(from=0L,to=1L) float progress, @NotNull Color other)
    Interpolate between this color and the specified other color in HSV space.
    @NotNull Color
    blendRgb(@Range(from=0L,to=1L) float progress, @NotNull Color other)
    Interpolate between this color and the specified other color.
    @NotNull Color
    Brighten the color by 25%.
    @NotNull Color
    brighten(@Range(from=0L,to=1L) float amount)
    Brighten the color.
    @NotNull Color
    Darken the color by 25%.
    @NotNull Color
    darken(@Range(from=0L,to=1L) float amount)
    Darken the color.
    @Range(from=0L,to=255L) int
    Get the alpha component.
    @Range(from=0L,to=255L) int
    Get the blue component.
    @Range(from=0L,to=255L) int
    Get the green component.
    @Range(from=0L,to=255L) int
    Get the red component.
    Get the hex code representation of this color.
    float @NotNull []
    hsv()
    Get the HSV (Hue Saturation Value) color components
    static Color
    hsv(float hue, float saturation, float value)
    Creates a color from the specified hue, saturation and value parameters
    float @NotNull []
    Get the HSVA (Hue Saturation Value Alpha) components.
    static Color
    hsva(float hue, float saturation, float value, float alpha)
    Creates a color from the specified hue, saturation, value and alpha parameters
    static Color
    lerpHsv(float progress, Color... colors)
    Interpolates between multiple colors in HSV color space.
    static Color
    lerpRgb(float progress, Color... colors)
    Interpolates between multiple colors.
    @NotNull Color
    multiplyArgb(float multiplier)
    Multiply the ARGB values by the specified multiplier
    @NotNull Color
    multiplyHsv(float multiplier)
    Convert the color to HSV and then multiply each component by the specified multiplier
    @NotNull Color
    multiplyHsv(float hue, float sat, float val)
    Convert the color to HSV and then multiply each component by the specified multiplier values
    @NotNull Color
    multiplyRgb(float multiplier)
    Multiply the RGB values by the specified multiplier
    int
    rgb()
    Get the RGB value of this color.
    static Color
    rgb(int rgb)
    Creates a color from the specified rgb value.
    static Color
    rgb(int red, int green, int blue)
    Creates a color object from the specified rgb components
    Get the SCSS string that can be used to represent this string.
  • Field Details

  • Method Details

    • rgb

      static Color rgb(int red, int green, int blue) throws IllegalArgumentException
      Creates a color object from the specified rgb components
      Parameters:
      red - Red component
      green - Green component
      blue - Blue component
      Returns:
      Created color
      Throws:
      IllegalArgumentException - If any color component is less than MIN_VALUE or greater than MAX_VALUE.
    • rgb

      static Color rgb(int rgb)
      Creates a color from the specified rgb value.
      Parameters:
      rgb - RGB color data
      Returns:
      Created color
    • argb

      static Color argb(int alpha, int red, int green, int blue) throws IllegalArgumentException
      Creates a color object from the specified rgb components
      Parameters:
      alpha - Alpha component
      red - Red component
      green - Green component
      blue - Blue component
      Returns:
      Created color
      Throws:
      IllegalArgumentException - If any color component is less than MIN_VALUE or greater than MAX_VALUE.
    • argb

      static Color argb(int argb)
      Creates a color from the specified argb value.
      Parameters:
      argb - ARGB color data
      Returns:
      Created color
    • hsv

      static Color hsv(float hue, float saturation, float value)
      Creates a color from the specified hue, saturation and value parameters
      Parameters:
      hue - Hue component (In range 0..1)
      saturation - Saturation component (In range 0..1)
      value - Value component (In range 0..1)
      Returns:
      Created color
    • hsva

      static Color hsva(float hue, float saturation, float value, float alpha)
      Creates a color from the specified hue, saturation, value and alpha parameters
      Parameters:
      hue - Hue component (In range 0..1)
      saturation - Saturation component (In range 0..1)
      value - Value component (In range 0..1)
      alpha - Alpha component (In range 0..1)
      Returns:
      Created color
    • lerpRgb

      @Contract("_, null -> null") static Color lerpRgb(float progress, Color... colors)
      Interpolates between multiple colors.

      If the colors array is empty or null, then null is returned. If only 1 color is specified, then that color is always returned. Otherwise, an interpolated color is returned.

      Parameters:
      progress - Interpolation value (In range 0..1)
      colors - Array of colors to interpolate between
      Returns:
      Interpolated colors.
    • lerpHsv

      static Color lerpHsv(float progress, Color... colors)
      Interpolates between multiple colors in HSV color space.

      If the colors array is empty or null, then null is returned. If only 1 color is specified, then that color is always returned. Otherwise, an interpolated color is returned.

      Parameters:
      progress - Interpolation value (In range 0..1)
      colors - Array of colors to interpolate between
      Returns:
      Interpolated colors.
    • getAlpha

      @Range(from=0L,to=255L) int getAlpha()
      Get the alpha component.
      Returns:
      Alpha component
    • getRed

      @Range(from=0L,to=255L) int getRed()
      Get the red component.
      Returns:
      Red component
    • getGreen

      @Range(from=0L,to=255L) int getGreen()
      Get the green component.
      Returns:
      Green component
    • getBlue

      @Range(from=0L,to=255L) int getBlue()
      Get the blue component.
      Returns:
      Blue component
    • hsv

      float @NotNull [] hsv()
      Get the HSV (Hue Saturation Value) color components
      Returns:
      HSV Color components
    • hsva

      float @NotNull [] hsva()
      Get the HSVA (Hue Saturation Value Alpha) components.
      Returns:
      HSVA Color components
    • argb

      int argb()
      Get the ARGB value of this color.

      Returned color bits: 0xAARRGGBB

      Returns:
      ARGB value
    • rgb

      int rgb()
      Get the RGB value of this color.

      Returned color bits: 0x00RRGGBB

      Returns:
      RGB value
    • brighten

      @NotNull @NotNull Color brighten()
      Brighten the color by 25%.

      Multiplies all channels by 25% and then adds that to the current value of the channel.

      Returns:
      Brightened color
      See Also:
    • brighten

      @NotNull @NotNull Color brighten(@Range(from=0L,to=1L) float amount)
      Brighten the color.

      Multiplies all channels by the specified amount and then adds that to the current value of the channel.

      Parameters:
      amount - Amount to brighten (In range 0..1)
      Returns:
      Brightened color
    • darken

      @NotNull @NotNull Color darken()
      Darken the color by 25%.

      Multiplies all channels by 25% and then subtracts that from the current value of the channel.

      Returns:
      Darkened color.
      See Also:
    • darken

      @NotNull @NotNull Color darken(@Range(from=0L,to=1L) float amount)
      Darken the color.

      Multiplies all channels by the specified amount and then subtracts that from the current value of the channel.

      Returns:
      Darkened color.
    • multiplyRgb

      @NotNull @NotNull Color multiplyRgb(float multiplier)
      Multiply the RGB values by the specified multiplier
      Parameters:
      multiplier - Multiplier
      Returns:
      Multiplied color
    • multiplyArgb

      @NotNull @NotNull Color multiplyArgb(float multiplier)
      Multiply the ARGB values by the specified multiplier
      Parameters:
      multiplier - Multiplier
      Returns:
      Multiplied color
    • multiplyHsv

      @NotNull @NotNull Color multiplyHsv(float multiplier)
      Convert the color to HSV and then multiply each component by the specified multiplier
      Parameters:
      multiplier - Multiplier
      Returns:
      Multiplied color
    • multiplyHsv

      @NotNull @NotNull Color multiplyHsv(float hue, float sat, float val)
      Convert the color to HSV and then multiply each component by the specified multiplier values
      Parameters:
      hue - Hue multiplier
      sat - Saturation multiplier
      val - Value multiplier
      Returns:
      Multiplied color
    • blendRgb

      @NotNull @NotNull Color blendRgb(@Range(from=0L,to=1L) float progress, @NotNull @NotNull Color other)
      Interpolate between this color and the specified other color.

      Interpolation is performed in RGB color space and is simply:

      
       self + ((other - self) * progress)
      Parameters:
      progress - Interpolation value (In range 0..1)
      other - Other color
      Returns:
      Interpolated color
    • blendHsv

      @NotNull @NotNull Color blendHsv(@Range(from=0L,to=1L) float progress, @NotNull @NotNull Color other)
      Interpolate between this color and the specified other color in HSV space.
      Parameters:
      progress - Interpolation value (In range 0..1)
      other - Other color
      Returns:
      Interpolated color
    • toString

      String toString()
      Get the SCSS string that can be used to represent this string.

      If the string's value matches a named color (Named colors defined in NamedColor), then the name is returned. Otherwise, a hex string representing this color is returned.

      Overrides:
      toString in class Object
      Returns:
      SCSS Color representation
    • hexString

      String hexString()
      Get the hex code representation of this color.
      Returns:
      Hex code