java.lang.Object
dev.prozilla.pine.common.system.resource.Color
All Implemented Interfaces:
Cloneable<Color>, Printable

public final class Color extends Object implements Printable, Cloneable<Color>
Represents an RGBA color.
  • Constructor Details

    • Color

      public Color()
      The default color is black.
    • Color

      public Color(Color color)
      Creates an RGB-Color from a java.awt.Color instance.
      Parameters:
      color - Color instance
    • Color

      public Color(float red, float green, float blue)
      Creates an RGB-Color with an alpha value of 1.
      Parameters:
      red - The red component. Range from 0f to 1f.
      green - The green component. Range from 0f to 1f.
      blue - The blue component. Range from 0f to 1f.
    • Color

      public Color(float red, float green, float blue, float alpha)
      Creates an RGBA-Color.
      Parameters:
      red - The red component. Range from 0f to 1f.
      green - The green component. Range from 0f to 1f.
      blue - The blue component. Range from 0f to 1f.
      alpha - The transparency. Range from 0f to 1f.
    • Color

      public Color(int red, int green, int blue)
      Creates an RGB-Color with an alpha value of 1.
      Parameters:
      red - The red component. Range from 0 to 255.
      green - The green component. Range from 0 to 255.
      blue - The blue component. Range from 0 to 255.
    • Color

      public Color(int red, int green, int blue, int alpha)
      Creates an RGBA-Color.
      Parameters:
      red - The red component. Range from 0 to 255.
      green - The green component. Range from 0 to 255.
      blue - The blue component. Range from 0 to 255.
      alpha - The transparency. Range from 0 to 255.
  • Method Details

    • copyRGB

      public Color copyRGB(Color color)
    • setRGB

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

      public Color setRGB(float red, float green, float blue)
    • getRed

      public float getRed()
      Returns the red component. Range from 0f to 1f.
      Returns:
      The red component.
    • setRed

      public Color setRed(float red)
      Sets the red component.
      Parameters:
      red - The red component. Range from 0f to 1f.
    • setRed

      public Color setRed(int red)
      Sets the red component.
      Parameters:
      red - The red component. Range from 0 to 255.
    • getGreen

      public float getGreen()
      Returns the green component. Range from 0f to 1f.
      Returns:
      The green component.
    • setGreen

      public Color setGreen(float green)
      Sets the green component.
      Parameters:
      green - The green component. Range from 0f to 1f.
    • setGreen

      public Color setGreen(int green)
      Sets the green component.
      Parameters:
      green - The green component. Range from 0 to 255.
    • getBlue

      public float getBlue()
      Returns the blue component. Range from 0f to 1f.
      Returns:
      The blue component.
    • setBlue

      public Color setBlue(float blue)
      Sets the blue component.
      Parameters:
      blue - The blue component. Range from 0f to 1f.
    • setBlue

      public Color setBlue(int blue)
      Sets the blue component.
      Parameters:
      blue - The blue component. Range from 0 to 255.
    • getAlpha

      public float getAlpha()
      Returns the transparency. Range from 0f to 1f.
      Returns:
      The transparency.
    • setAlpha

      public Color setAlpha(float alpha)
      Sets the transparency.
      Parameters:
      alpha - The transparency. Range from 0f to 1f.
    • setAlpha

      public Color setAlpha(int alpha)
      Sets the transparency.
      Parameters:
      alpha - The transparency. Range from 0 to 255.
    • multiply

      public Color multiply(float scalar)
    • mix

      public Color mix(Color color)
      Mixes half of this color with half of another color.
      Parameters:
      color - Color to mix with this color
    • mix

      public Color mix(Color color, float factor)
      Mixes this color with another color based on a factor.
      Parameters:
      color - Color to mix with this color
      factor - Mixing factor, Range from 0f to 1f.
    • toVector3f

      public Vector3f toVector3f()
      Returns the color as a (x,y,z)-Vector.
      Returns:
      The color as vec3.
    • toVector4f

      public Vector4f toVector4f()
      Returns the color as a (x,y,z,w)-Vector.
      Returns:
      The color as vec4.
    • equals

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

      public boolean equals(Color color)
      Checks if two colors are equal. Two colors are equal if they share the same R, G, B and A values.
      Specified by:
      equals in interface Cloneable<Color>
      Parameters:
      color - Color to compare with
      Returns:
      true if both objects are equal.
    • clone

      public Color clone()
      Description copied from interface: Cloneable
      Returns a new object that is equal to this object.
      Specified by:
      clone in interface Cloneable<Color>
      Overrides:
      clone in class Object
      Returns:
      Clone of this object
    • toString

      public String toString()
      Description copied from interface: Printable
      Returns a string representation of this object.
      Specified by:
      toString in interface Printable
      Overrides:
      toString in class Object
      Returns:
      String representation of this object.
    • white

      public static Color white()
    • black

      public static Color black()
    • red

      public static Color red()
    • green

      public static Color green()
    • blue

      public static Color blue()
    • decode

      public static Color decode(String nm) throws NumberFormatException
      Decodes a String into a Color. Supports octal and hexadecimal number representations of opaque colors.
      Parameters:
      nm - String that represents a color as a 24-bit integer
      Returns:
      Color
      Throws:
      NumberFormatException - If the string cannot be decoded.