Package zombie.core

Class Color

java.lang.Object
zombie.core.Color
All Implemented Interfaces:
Serializable

public final class Color extends Object implements Serializable
A simple wrapper round the values required for a colour
See Also:
  • Field Details

    • transparent

      public static final Color transparent
      The fixed color transparent
    • white

      public static final Color white
      The fixed colour white
    • yellow

      public static final Color yellow
      The fixed colour yellow
    • red

      public static final Color red
      The fixed colour red
    • purple

      public static final Color purple
      The fixed colour purple
    • blue

      public static final Color blue
      The fixed colour blue
    • green

      public static final Color green
      The fixed colour green
    • black

      public static final Color black
      The fixed colour black
    • gray

      public static final Color gray
      The fixed colour gray
    • cyan

      public static final Color cyan
      The fixed colour cyan
    • darkGray

      public static final Color darkGray
      The fixed colour dark gray
    • lightGray

      public static final Color lightGray
      The fixed colour light gray
    • pink

      public static final Color pink
      The fixed colour dark pink
    • orange

      public static final Color orange
      The fixed colour dark orange
    • magenta

      public static final Color magenta
      The fixed colour dark magenta
    • darkGreen

      public static final Color darkGreen
      The fixed colour dark green
    • lightGreen

      public static final Color lightGreen
      The fixed colour light green
    • a

      public float a
      The alpha component of the colour
    • b

      public float b
      The blue component of the colour
    • g

      public float g
      The green component of the colour
    • r

      public float r
      The red component of the colour
  • Constructor Details

    • Color

      public Color()
    • Color

      public Color(Color color)
      Copy constructor
      Parameters:
      color - The color to copy into the new instance
    • Color

      public Color(float r, float g, float b)
      Create a 3 component colour
      Parameters:
      r - The red component of the colour (0.0 -> 1.0)
      g - The green component of the colour (0.0 -> 1.0)
      b - The blue component of the colour (0.0 -> 1.0)
    • Color

      public Color(float r, float g, float b, float a)
      Create a 4 component colour
      Parameters:
      r - The red component of the colour (0.0 -> 1.0)
      g - The green component of the colour (0.0 -> 1.0)
      b - The blue component of the colour (0.0 -> 1.0)
      a - The alpha component of the colour (0.0 -> 1.0)
    • Color

      public Color(Color A, Color B, float delta)
    • Color

      public Color(int r, int g, int b)
      Create a 3 component colour
      Parameters:
      r - The red component of the colour (0 -> 255)
      g - The green component of the colour (0 -> 255)
      b - The blue component of the colour (0 -> 255)
    • Color

      public Color(int r, int g, int b, int a)
      Create a 4 component colour
      Parameters:
      r - The red component of the colour (0 -> 255)
      g - The green component of the colour (0 -> 255)
      b - The blue component of the colour (0 -> 255)
      a - The alpha component of the colour (0 -> 255)
    • Color

      public Color(int value)
      Create a colour from an evil integer packed 0xAARRGGBB. If AA is specified as zero then it will be interpreted as unspecified and hence a value of 255 will be recorded.
      Parameters:
      value - The value to interpret for the colour
  • Method Details

    • setColor

      public void setColor(Color A, Color B, float delta)
    • fromColor

      @Deprecated public void fromColor(int valueABGR)
      Deprecated.
      Performs special-case processing on the supplied value. Recommend use argbToColor instead.
      Converts the supplied binary value into color values, and sets the result to this object. Performs a clamp on the alpha channel. Performs a special-case on the alpha channel, where if it is 0, it is set to MAX instead.
      Parameters:
      valueABGR -
    • setABGR

      public void setABGR(int valueABGR)
    • abgrToColor

      public static Color abgrToColor(int valueABGR, Color out_result)
    • colorToABGR

      public static int colorToABGR(Color val)
    • colorToABGR

      public static int colorToABGR(float r, float g, float b, float a)
    • multiplyABGR

      public static int multiplyABGR(int valueABGR, int multiplierABGR)
    • multiplyBGR

      public static int multiplyBGR(int valueABGR, int multiplierABGR)
    • blendBGR

      public static int blendBGR(int valueABGR, int targetABGR)
    • blendABGR

      public static int blendABGR(int valueABGR, int targetABGR)
    • tintABGR

      public static int tintABGR(int targetABGR, int tintABGR)
    • lerpABGR

      public static int lerpABGR(int colA, int colB, float alpha)
    • getAlphaChannelFromABGR

      public static float getAlphaChannelFromABGR(int valueABGR)
    • getBlueChannelFromABGR

      public static float getBlueChannelFromABGR(int valueABGR)
    • getGreenChannelFromABGR

      public static float getGreenChannelFromABGR(int valueABGR)
    • getRedChannelFromABGR

      public static float getRedChannelFromABGR(int valueABGR)
    • setAlphaChannelToABGR

      public static int setAlphaChannelToABGR(int valueABGR, float a)
    • setBlueChannelToABGR

      public static int setBlueChannelToABGR(int valueABGR, float b)
    • setGreenChannelToABGR

      public static int setGreenChannelToABGR(int valueABGR, float g)
    • setRedChannelToABGR

      public static int setRedChannelToABGR(int valueABGR, float r)
    • random

      public static Color random()
      Create a random color.
    • decode

      public static Color decode(String nm)
      Decode a number in a string and process it as a colour reference.
      Parameters:
      nm - The number string to decode
      Returns:
      The color generated from the number read
    • add

      public void add(Color c)
      Add another colour to this one
      Parameters:
      c - The colour to add
    • addToCopy

      public Color addToCopy(Color c)
      Add another colour to this one
      Parameters:
      c - The colour to add
      Returns:
      The copy which has had the color added to it
    • brighter

      public Color brighter()
      Make a brighter instance of this colour
      Returns:
      The brighter version of this colour
    • brighter

      public Color brighter(float scale)
      Make a brighter instance of this colour
      Parameters:
      scale - The scale up of RGB (i.e. if you supply 0.03 the colour will be brightened by 3%)
      Returns:
      The brighter version of this colour
    • darker

      public Color darker()
      Make a darker instance of this colour
      Returns:
      The darker version of this colour
    • darker

      public Color darker(float scale)
      Make a darker instance of this colour
      Parameters:
      scale - The scale down of RGB (i.e. if you supply 0.03 the colour will be darkened by 3%)
      Returns:
      The darker version of this colour
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
      See Also:
    • set

      public Color set(Color other)
    • set

      public Color set(float r, float g, float b)
    • set

      public Color set(float r, float g, float b, float a)
    • getAlpha

      public int getAlpha()
      get the alpha byte component of this colour
      Returns:
      The alpha component (range 0-255)
    • getAlphaFloat

      public float getAlphaFloat()
    • getRedFloat

      public float getRedFloat()
    • getGreenFloat

      public float getGreenFloat()
    • getBlueFloat

      public float getBlueFloat()
    • getAlphaByte

      public int getAlphaByte()
      get the alpha byte component of this colour
      Returns:
      The alpha component (range 0-255)
    • getBlue

      public int getBlue()
      get the blue byte component of this colour
      Returns:
      The blue component (range 0-255)
    • getBlueByte

      public int getBlueByte()
      get the blue byte component of this colour
      Returns:
      The blue component (range 0-255)
    • getGreen

      public int getGreen()
      get the green byte component of this colour
      Returns:
      The green component (range 0-255)
    • getGreenByte

      public int getGreenByte()
      get the green byte component of this colour
      Returns:
      The green component (range 0-255)
    • getRed

      public int getRed()
      get the red byte component of this colour
      Returns:
      The red component (range 0-255)
    • getRedByte

      public int getRedByte()
      get the red byte component of this colour
      Returns:
      The red component (range 0-255)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • multiply

      public Color multiply(Color c)
      Multiply this color by another
      Parameters:
      c - the other color
      Returns:
      product of the two colors
    • scale

      public Color scale(float value)
      Scale the components of the colour by the given value
      Parameters:
      value - The value to scale by
    • scaleCopy

      public Color scaleCopy(float value)
      Scale the components of the colour by the given value
      Parameters:
      value - The value to scale by
      Returns:
      The copy which has been scaled
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • interp

      public void interp(Color to, float delta, Color dest)
    • changeHSBValue

      public void changeHSBValue(float hFactor, float sFactor, float bFactor)
    • HSBtoRGB

      public static Color HSBtoRGB(float hue, float saturation, float brightness, Color result)
    • HSBtoRGB

      public static Color HSBtoRGB(float hue, float saturation, float brightness)