Interface Color

All Known Implementing Classes:
ImmutableColor, MutableColor

public interface Color
A robust RGBA color class with support for multiple color spaces, conversion routines, and named‐color parsing.
  • Field Details

  • Method Details

    • r

      float r()
      Red component [0..1]
    • g

      float g()
      Green component [0..1]
    • b

      float b()
      Blue component [0..1]
    • a

      float a()
      Alpha component [0..1]
    • withValues

      Color withValues(float r, float g, float b, float a)
    • withValues

      Color withValues(float r, float g, float b)
    • toImmutable

      default ImmutableColor toImmutable()
    • toMutable

      default MutableColor toMutable()
    • parse

      @Nonnull static ImmutableColor parse(@Nonnull String input)
      Parses a color from a string. Supports: Named colors via Color.named(name) Hex: "#RGB", "#RGBA", "#RRGGBB", "#RRGGBBAA", with optional "0x" prefix Integer literals: decimal or hex (via Integer.decode) If parsing fails, throws IllegalArgumentException.
    • toHexRGBString

      default String toHexRGBString()
    • fromIntARGB

      @Nonnull static ImmutableColor fromIntARGB(int argb)
      Creates a Color from a packed ARGB int (0xAARRGGBB).
      Parameters:
      argb - packed color ARGB
      Returns:
      new IColor
    • fromIntRGB

      @Nonnull static ImmutableColor fromIntRGB(int rgb)
      Creates a Color from a packed RGB int (0xRRGGBB). Alpha defaults to 1.0.
      Parameters:
      rgb - packed color
      Returns:
      new IColor
    • fromIntRGBA

      @Nonnull static ImmutableColor fromIntRGBA(int rgba)
      Creates a Color from a packed RGBA int (0xRRGGBBAA).
      Parameters:
      rgba - packed color in RRGGBBAA format
      Returns:
      new IColor instance
    • fromHSV

      @Nonnull static ImmutableColor fromHSV(float h, float s, float v)
      Creates a Color from HSB/HSV values (all in [0..1]). HSB and HSV are identical.
      Parameters:
      h - hue (0.0–1.0)
      s - saturation (0.0–1.0)
      v - brightness (0.0–1.0)
      Returns:
      new IColor
    • fromHSV

      @Nonnull static void fromHSV(float h, float s, float v, Color out)
      Outputs a Color from HSB/HSV values (all in [0..1]). HSB and HSV are identical. All values aside from alpha will be modified
      Parameters:
      h - hue (0.0–1.0)
      s - saturation (0.0–1.0)
      v - brightness (0.0–1.0)
      out - the color being modified
    • fromHSL

      @Nonnull static ImmutableColor fromHSL(float h, float s, float l)
      Creates a Color from HSL values (all in [0..1]), alpha defaults to 1.
      Parameters:
      h - hue (0.0–1.0)
      s - saturation (0.0–1.0)
      l - lightness (0.0–1.0)
      Returns:
      new IColor
    • fromHSL

      @Nonnull static ImmutableColor fromHSL(float h, float s, float l, float a)
      Creates a Color from HSLA values (all in [0..1]).
      Parameters:
      h - hue (0.0–1.0)
      s - saturation (0.0–1.0)
      l - lightness (0.0–1.0)
      a - alpha (0.0–1.0)
      Returns:
      new IColor
    • fromCMYK

      @Nonnull static ImmutableColor fromCMYK(float c, float m, float y, float k)
      Creates a Color from CMYK values (all in [0..1]), alpha defaults to 1.
      Parameters:
      c - cyan (0.0–1.0)
      m - magenta (0.0–1.0)
      y - yellow (0.0–1.0)
      k - key/black (0.0–1.0)
      Returns:
      new IColor
    • toIntARGB

      default int toIntARGB()
      Packs this color into a 32‐bit ARGB int (0xAARRGGBB). Each channel is multiplied by 255 and floored.
    • toIntRGB

      default int toIntRGB()
      Packs this color into a 24‐bit RGB int (0xRRGGBB), discarding alpha.
    • toIntRGBA

      default int toIntRGBA()
      Packs this color into 32‐bit RGBA int (0xRRGGBBAA).
    • getRedInt

      default int getRedInt()
      Returns:
      red channel as 0–255 int.
    • getGreenInt

      default int getGreenInt()
      Returns:
      green channel as 0–255 int.
    • getBlueInt

      default int getBlueInt()
      Returns:
      blue channel as 0–255 int.
    • getAlphaInt

      default int getAlphaInt()
      Returns:
      alpha channel as 0–255 int.
    • toHSV

      @Nonnull default float[] toHSV()
      Converts this RGB color to HSB/HSV (hue, saturation, brightness), each in [0..1]. HSB is identical to HSV.
      Returns:
      float[3] = {h, s, v}
    • toHSL

      @Nonnull default float[] toHSL()
      Converts this RGB color to HSL (hue, saturation, lightness), each in [0..1].
      Returns:
      float[3] = {h, s, l}
    • toHSLA

      @Nonnull default float[] toHSLA()
      Converts this RGB color to HSLA (hue, saturation, lightness, alpha), each in [0..1].
      Returns:
      float[4] = {h, s, l, a}
    • toCMYK

      @Nonnull default float[] toCMYK()
      Converts this RGB color to CMYK (cyan, magenta, yellow, key/black), each in [0..1].
      Returns:
      float[4] = {c, m, y, k}
    • lerp

      @Nonnull Color lerp(@Nonnull Color other, float t)
      Returns a new Color that is the linear interpolation between this and other.
      Parameters:
      other - target color
      t - interpolation factor [0..1]
    • lerp

      @Nonnull default <T extends Color> T lerp(@Nonnull Color other, float t, Funcs._4<Float,Float,Float,Float,T> setColor)
    • multiply

      @Nonnull Color multiply(@Nonnull Color other)
      Returns a new Color that is this color multiplied component‐wise by other.
      Parameters:
      other - multiplier color
    • multiply

      @Nonnull default <T extends Color> T multiply(@Nonnull Color other, Funcs._4<Float,Float,Float,Float,T> setColor)
    • blend

      @Nonnull Color blend(@Nonnull Color over)
      Alpha‐composites over on top of this color (this = “background,” over = “foreground”).
    • blend

      @Nonnull default <T extends Color> T blend(@Nonnull Color over, Funcs._4<Float,Float,Float,Float,T> setColor)
    • invert

      @Nonnull Color invert()
      Returns an inverted‐color version of this color (ignoring alpha).
    • invert

      @Nonnull default <T extends Color> T invert(Funcs._4<Float,Float,Float,Float,T> setColor)
    • grayscale

      @Nonnull Color grayscale()
      Returns a grayscale version of this color, preserving alpha. Uses standard luminosity formula: gray = 0.299R + 0.587G + 0.114B.
    • grayscale

      @Nonnull default <T extends Color> T grayscale(Funcs._4<Float,Float,Float,Float,T> setColor)
    • brighten

      Color brighten(float factor)
      Returns a brighter version of this color by multiplying each RGB by factor (>1). Alpha is unchanged.
    • brighten

      @Nonnull default <T extends Color> T brighten(float factor, Funcs._4<Float,Float,Float,Float,T> setColor)
    • darken

      @Nonnull Color darken(float factor)
      Returns a darker version of this color by dividing each RGB by factor (>1). Alpha is unchanged.
    • darken

      @Nonnull default <T extends Color> T darken(float factor, Funcs._4<Float,Float,Float,Float,T> setColor)
    • r

      @Nonnull Color r(float red)
      Sets the red value of this color.
    • r

      @Nonnull default <T extends Color> T r(float red, Funcs._4<Float,Float,Float,Float,T> setColor)
    • g

      @Nonnull Color g(float green)
      Sets the green value of this color.
    • g

      @Nonnull default <T extends Color> T g(float green, Funcs._4<Float,Float,Float,Float,T> setColor)
    • b

      @Nonnull Color b(float blue)
      Sets the blue value of this color.
    • b

      @Nonnull default <T extends Color> T b(float blue, Funcs._4<Float,Float,Float,Float,T> setColor)
    • a

      @Nonnull Color a(float alpha)
      Sets the alpha of this color.
    • a

      @Nonnull default <T extends Color> T a(float alpha, Funcs._4<Float,Float,Float,Float,T> setColor)
    • colorEquals

      default boolean colorEquals(Object obj)
    • colorHashCode

      default int colorHashCode()
    • colorToString

      default String colorToString()