java.lang.Object
io.github.xrickastley.sevenelements.util.Color

public final class Color extends Object
  • Field Details

    • red

      private final int red
    • green

      private final int green
    • blue

      private final int blue
    • alpha

      private final float alpha
  • Constructor Details

    • Color

      public Color(int red, int green, int blue)
    • Color

      public Color(int red, int green, int blue, float alpha)
    • Color

      private Color(double red, double green, double blue, double alpha)
  • Method Details

    • getRed

      public int getRed()
    • getGreen

      public int getGreen()
    • getBlue

      public int getBlue()
    • getAlpha

      public float getAlpha()
    • getRedAsPercent

      public float getRedAsPercent()
      Gets the red value as a percent.
      Returns:
      The red value as a percent from 0 to 255, defined as red / 255.
    • getGreenAsPercent

      public float getGreenAsPercent()
      Gets the green value as a percent.
      Returns:
      The red value as a percent from 0 to 255, defined as blue / 255.
    • getBlueAsPercent

      public float getBlueAsPercent()
      Gets the blue value as a percent.
      Returns:
      The blue value as a percent from 0 to 255, defined as blue / 255.
    • getAlphaAsRange

      public int getAlphaAsRange()
      Gets the alpha value as a number.
      Returns:
      The alpha value as a number in the range 0 to 255, defined as alpha * 255.
    • asHex

      public String asHex()
    • asRGB

      public int asRGB()
    • asARGB

      public int asARGB()
    • from

      public Color from()
      Creates a new Color based on the values of this color.
      Returns:
      The new Color
    • add

      public Color add(double factor)
      Adds factor to this Color.
      Parameters:
      factor - The factor to add to this color.
      Returns:
      This Color object.
    • add

      public Color add(double r, double g, double b)
      Adds all the values of this Color by their respective factors.
      Parameters:
      r - The factor to add to the red value.
      g - The factor to add to the green value.
      b - The factor to add to the blue value.
      Returns:
      This Color object.
    • add

      public Color add(double r, double g, double b, double a)
      Adds all the values of this Color by their respective factors.
      Parameters:
      r - The factor to add to the red value.
      g - The factor to add to the green value.
      b - The factor to add to the blue value.
      a - The factor to add to the alpha value.
      Returns:
      This Color object.
    • multiply

      public Color multiply(double factor)
      Creates a new color based on this Color multiplied by factor.
      Parameters:
      factor - The factor to multiply this color with.
      Returns:
      The resulting Color object.
    • multiply

      public Color multiply(double r, double g, double b)
      Creates a new color based on this Color multiplied by their respective factors.
      Parameters:
      r - The factor to multiply the red value with.
      g - The factor to multiply the green value with.
      b - The factor to multiply the blue value with.
      Returns:
      The resulting Color object.
    • multiply

      public Color multiply(double r, double g, double b, double a)
      Creates a new color based on this Color multiplied by their respective factors.
      Parameters:
      r - The factor to multiply the red value with.
      g - The factor to multiply the green value with.
      b - The factor to multiply the blue value with.
      a - The factor to multiply the alpha value with.
      Returns:
      The resulting Color object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromRGBAHex

      public static Color fromRGBAHex(String rgbaHex)
      Turns an RGBA hex string #rrggbbaa to a Color object. This method also permits RGB hex strings #rrggbb and will use 1 as the value for the alpha.
      Parameters:
      rgbaHex - An RGBA hex string #rrggbbaa or an RGB hex string #rrggbb
      Returns:
      A Color object created from the provided hex string.
    • fromARGBHex

      public static Color fromARGBHex(int argbHex)
    • gradient

      public static List<Color> gradient(Color start, Color end, int steps)
    • gradient

      public static List<Color> gradient(Color start, Color end, int steps, Ease ease)
    • gradientStep

      public static Color gradientStep(Color start, Color end, double step)
    • gradientStep

      public static Color gradientStep(Color start, Color end, double step, Ease ease)