Class Color

java.lang.Object
foundry.veil.api.client.color.Color
All Implemented Interfaces:
Colorc

public class Color extends Object implements Colorc
A representation of color as four floating point elements.
Since:
1.0.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<Colorc>
    Allows ARGB components.
    static final com.mojang.serialization.Codec<Integer>
    Allows ARGB components.
    static final Colorc
     
    static final Colorc
     
    static final Colorc
     
    static final Colorc
     
    static final com.mojang.serialization.Codec<Colorc>
    Allows only RGB components with a full alpha component.
    static final com.mojang.serialization.Codec<Integer>
    Allows only RGB components with a full alpha component.
    static final Colorc
     
    static final Colorc
     
    static final Colorc
     
    static final Colorc
     
    static final Colorc
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new black color with full alpha.
    Color(float red, float green, float blue)
    Sets the red, green, and blue components of this color.
    Color(float red, float green, float blue, float alpha)
    Sets the red, green, blue, and alpha components of this color.
    Color(int rgb)
    Creates a new color with the specified RGB values.
    Color(int color, boolean alpha)
    Creates a new color with the specified ARGB values.
    Color(Colorc copy)
    Copies the color from the specified color.
    Color(org.joml.Vector3fc copy)
    Copies the color from the specified vector.
    Color(org.joml.Vector4fc copy)
    Copies the color from the specified vector.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
     
    alpha(float alpha)
    Sets the value of the alpha component.
    alphaInt(int alpha)
    Sets the value of the alpha component from 0 to 255.
    float
     
    blue(float blue)
    Sets the value of the blue component.
    blueInt(int blue)
    Sets the value of the blue component from 0 to 255.
    darken(float amount)
    Mixes this color with black to "darken" it.
    boolean
     
    Applies a grayscale filter to this color.
    float
     
    green(float green)
    Sets the value of the green component.
    greenInt(int green)
    Sets the value of the green component from 0 to 255.
    int
     
    Inverts this color.
    lerp(Colorc other, float delta)
    Linearly interpolates between this color and the specified color.
    lighten(float amount)
    Mixes this color with white to "brighten" it.
    mix(Colorc color, float amount)
    Mixes this color with the specified color.
    float
    red()
     
    red(float red)
    Sets the value of the red component.
    redInt(int red)
    Sets the value of the red component from 0 to 255.
    Applies a sepia filter to this color.
    set(float red, float green, float blue)
    Sets the red, green, and blue components of this color.
    set(float red, float green, float blue, float alpha)
    Sets the red, green, blue, and alpha components of this color.
    set(Colorc color)
    Sets the red, green, blue, and alpha components of this color.
    setARGB(int argb)
    Sets the red, green, blue, and alpha components of this color to the specified value.
    setHSV(float hue, float saturation, float luminance)
    Converts the specified hue, saturation, and luminance values (HSV) to RGB.
    setHue(float hue)
    Converts the specified hue value (HSV) to RGB.
    setInt(int red, int green, int blue)
    Sets the red, green, and blue components of this color as ints from 0 to 255.
    setInt(int red, int green, int blue, int alpha)
    Sets the red, green, blue, and alpha components of this color as ints from 0 to 255.
    setLuminance(float luminance)
    Converts the specified luminance value (HSV) to RGB.
    setRGB(int rgb)
    Sets the red, green, and blue components of this color to the specified value.
    setSaturation(float saturation)
    Converts the specified saturation value (HSV) to RGB.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RGB_INT_CODEC

      public static final com.mojang.serialization.Codec<Integer> RGB_INT_CODEC
      Allows only RGB components with a full alpha component.
    • ARGB_INT_CODEC

      public static final com.mojang.serialization.Codec<Integer> ARGB_INT_CODEC
      Allows ARGB components.
    • RGB_CODEC

      public static final com.mojang.serialization.Codec<Colorc> RGB_CODEC
      Allows only RGB components with a full alpha component.
    • ARGB_CODEC

      public static final com.mojang.serialization.Codec<Colorc> ARGB_CODEC
      Allows ARGB components.
    • WHITE

      public static final Colorc WHITE
    • BLACK

      public static final Colorc BLACK
    • RED

      public static final Colorc RED
    • GREEN

      public static final Colorc GREEN
    • BLUE

      public static final Colorc BLUE
    • TRANSPARENT

      public static final Colorc TRANSPARENT
    • VANILLA_TOOLTIP_BACKGROUND

      public static final Colorc VANILLA_TOOLTIP_BACKGROUND
    • VANILLA_TOOLTIP_BORDER_TOP

      public static final Colorc VANILLA_TOOLTIP_BORDER_TOP
    • VANILLA_TOOLTIP_BORDER_BOTTOM

      public static final Colorc VANILLA_TOOLTIP_BORDER_BOTTOM
  • Constructor Details

    • Color

      public Color()
      Creates a new black color with full alpha.
    • Color

      public Color(int rgb)
      Creates a new color with the specified RGB values.
      Parameters:
      rgb - The color values formatted as RRGGBB
      See Also:
    • Color

      public Color(int color, boolean alpha)
      Creates a new color with the specified ARGB values.
      Parameters:
      color - The color values formatted as AARRGGBB
      alpha - Whether the color values contain an alpha component
    • Color

      public Color(float red, float green, float blue)
      Sets the red, green, and blue components of this color.
      Parameters:
      red - The red amount
      green - The green amount
      blue - The blue amount
    • Color

      public Color(float red, float green, float blue, float alpha)
      Sets the red, green, blue, and alpha components of this color.
      Parameters:
      red - The red amount
      green - The green amount
      blue - The blue amount
      alpha - The alpha amount
    • Color

      public Color(Colorc copy)
      Copies the color from the specified color.
      Parameters:
      copy - The color to copy from
    • Color

      public Color(org.joml.Vector3fc copy)
      Copies the color from the specified vector.
      Parameters:
      copy - The vector to copy from
      Since:
      2.5.0
    • Color

      public Color(org.joml.Vector4fc copy)
      Copies the color from the specified vector.
      Parameters:
      copy - The vector to copy from
      Since:
      2.5.0
  • Method Details

    • red

      public Color red(float red)
      Sets the value of the red component.
      Parameters:
      red - The new red value
      Returns:
      This color
    • green

      public Color green(float green)
      Sets the value of the green component.
      Parameters:
      green - The new green value
      Returns:
      This color
    • blue

      public Color blue(float blue)
      Sets the value of the blue component.
      Parameters:
      blue - The new blue value
      Returns:
      This color
    • alpha

      public Color alpha(float alpha)
      Sets the value of the alpha component.
      Parameters:
      alpha - The new alpha value
      Returns:
      This color
    • redInt

      public Color redInt(int red)
      Sets the value of the red component from 0 to 255.
      Parameters:
      red - The new red value
      Returns:
      This color
    • greenInt

      public Color greenInt(int green)
      Sets the value of the green component from 0 to 255.
      Parameters:
      green - The new green value
      Returns:
      This color
    • blueInt

      public Color blueInt(int blue)
      Sets the value of the blue component from 0 to 255.
      Parameters:
      blue - The new blue value
      Returns:
      This color
    • alphaInt

      public Color alphaInt(int alpha)
      Sets the value of the alpha component from 0 to 255.
      Parameters:
      alpha - The new alpha value
      Returns:
      This color
    • set

      public Color set(Colorc color)
      Sets the red, green, blue, and alpha components of this color.
      Parameters:
      color - The new color
      Returns:
      This color
    • set

      public Color set(float red, float green, float blue)
      Sets the red, green, and blue components of this color.
      Parameters:
      red - The new red amount
      green - The new green amount
      blue - The new blue amount
      Returns:
      This color
    • set

      public Color set(float red, float green, float blue, float alpha)
      Sets the red, green, blue, and alpha components of this color.
      Parameters:
      red - The new red amount
      green - The new green amount
      blue - The new blue amount
      alpha - The new alpha amount
      Returns:
      This color
    • setInt

      public Color setInt(int red, int green, int blue)
      Sets the red, green, and blue components of this color as ints from 0 to 255.
      Parameters:
      red - The new red amount
      green - The new green amount
      blue - The new blue amount
      Returns:
      This color
    • setInt

      public Color setInt(int red, int green, int blue, int alpha)
      Sets the red, green, blue, and alpha components of this color as ints from 0 to 255.
      Parameters:
      red - The new red amount
      green - The new green amount
      blue - The new blue amount
      alpha - The new alpha amount
      Returns:
      This color
    • setRGB

      public Color setRGB(int rgb)
      Sets the red, green, and blue components of this color to the specified value.
      Parameters:
      rgb - The color values formatted as RRGGBB
      Returns:
      This color
    • setARGB

      public Color setARGB(int argb)
      Sets the red, green, blue, and alpha components of this color to the specified value.
      Parameters:
      argb - The color values formatted as AARRGGBB
      Returns:
      This color
    • red

      public float red()
      Specified by:
      red in interface Colorc
      Returns:
      The red component of this color
    • green

      public float green()
      Specified by:
      green in interface Colorc
      Returns:
      The green component of this color
    • blue

      public float blue()
      Specified by:
      blue in interface Colorc
      Returns:
      The blue component of this color
    • alpha

      public float alpha()
      Specified by:
      alpha in interface Colorc
      Returns:
      The alpha component of this color
    • lerp

      public Color lerp(Colorc other, float delta)
      Linearly interpolates between this color and the specified color.
      Parameters:
      other - The other color to store in
      delta - The delta from 0 to 1
      Returns:
      This color
    • mix

      public Color mix(Colorc color, float amount)
      Mixes this color with the specified color.
      Parameters:
      color - The color to mix with
      amount - The amount of that color to mix from 0 to 1
      Returns:
      This color
    • lighten

      public Color lighten(float amount)
      Mixes this color with white to "brighten" it.
      Parameters:
      amount - The amount of white to add
      Returns:
      This color
    • darken

      public Color darken(float amount)
      Mixes this color with black to "darken" it.
      Parameters:
      amount - The amount of black to add
      Returns:
      This color
    • invert

      public Color invert()
      Inverts this color.
      Returns:
      This color
    • grayscale

      public Color grayscale()
      Applies a grayscale filter to this color.
      Returns:
      The passed in color
    • sepia

      public Color sepia()
      Applies a sepia filter to this color.
      Returns:
      The passed in color
    • setHue

      public Color setHue(float hue)
      Converts the specified hue value (HSV) to RGB.
      Parameters:
      hue - The hue angle from 0 to 360 degrees
      Returns:
      This color
    • setSaturation

      public Color setSaturation(float saturation)
      Converts the specified saturation value (HSV) to RGB.
      Parameters:
      saturation - The saturation percentage from 0 to 1
      Returns:
      This color
    • setLuminance

      public Color setLuminance(float luminance)
      Converts the specified luminance value (HSV) to RGB.
      Parameters:
      luminance - The brightness percentage from 0 to 1
      Returns:
      This color
    • setHSV

      public Color setHSV(float hue, float saturation, float luminance)
      Converts the specified hue, saturation, and luminance values (HSV) to RGB.
      Parameters:
      hue - The hue angle from 0 to 360 degrees
      saturation - The saturation percentage from 0 to 1
      luminance - The brightness percentage from 0 to 1
      Returns:
      This color
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object