de.lessvoid.nifty.tools
Class Color

java.lang.Object
  extended by de.lessvoid.nifty.tools.Color

public class Color
extends Object

Color helper class to manage colors.

Author:
void

Field Summary
static Color BLACK
          a black color.
static Color NONE
          the default empty color.
static Color WHITE
          a white color.
 
Constructor Summary
Color(Color colorParam)
           
Color(Color newColor, float newAlpha)
          Create a color from another color, using the given alpha value.
Color(float newRed, float newGreen, float newBlue, float newAlpha)
          Create a color from components.
Color(int color)
          Create a color from an encoded int value alpha + R + G + B.
Color(String color)
          Create a color from a color String formated like in html code but with alpha, e.g.: "#ff00ffff".
 
Method Summary
static boolean check(String color)
           
 void fromString(String color)
           
 void fromStringWithoutAlpha(String color)
           
 float getAlpha()
          get alpha value.
 float getBlue()
          get the blue component.
 String getColorString()
           
 String getColorStringWithoutAlpha()
           
 float getGreen()
          get the green component.
 float getRed()
          get the red component.
 void linear(Color start, Color end, float t)
          linear interpolate between the start color and the end color and updates this color.
 void mutiply(Color color, float factor)
          Multiply all components with the given factor.
static Color randomColor()
           
 Color setAlpha(float newColorAlpha)
          Set color alpha.
 void setBlue(float newBlue)
          Set blue.
 void setColorString(String colorString)
           
 void setGreen(float newGreen)
          Set green.
 void setRed(float newRed)
          Set red.
 String toString()
          convert color to string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final Color NONE
the default empty color.


WHITE

public static final Color WHITE
a white color.


BLACK

public static final Color BLACK
a black color.

Constructor Detail

Color

public Color(String color)
Create a color from a color String formated like in html code but with alpha, e.g.: "#ff00ffff".

Parameters:
color - the color string

Color

public Color(float newRed,
             float newGreen,
             float newBlue,
             float newAlpha)
Create a color from components.

Parameters:
newRed - red component
newGreen - green component
newBlue - blue component
newAlpha - alpha component

Color

public Color(int color)
Create a color from an encoded int value alpha + R + G + B.

Parameters:
color - color value

Color

public Color(Color newColor,
             float newAlpha)
Create a color from another color, using the given alpha value.

Parameters:
newColor - color
newAlpha - alpha component

Color

public Color(Color colorParam)
Method Detail

getColorString

public String getColorString()

setColorString

public void setColorString(String colorString)

getColorStringWithoutAlpha

public String getColorStringWithoutAlpha()

linear

public void linear(Color start,
                   Color end,
                   float t)
linear interpolate between the start color and the end color and updates this color.

Parameters:
start - start color
end - end color
t - t in [0,1]

getRed

public float getRed()
get the red component.

Returns:
red

getGreen

public float getGreen()
get the green component.

Returns:
green

getBlue

public float getBlue()
get the blue component.

Returns:
blue

getAlpha

public float getAlpha()
get alpha value.

Returns:
alpha

mutiply

public void mutiply(Color color,
                    float factor)
Multiply all components with the given factor.

Parameters:
factor - factor to multiply

toString

public String toString()
convert color to string.

Overrides:
toString in class Object
Returns:
string representation

setAlpha

public Color setAlpha(float newColorAlpha)
Set color alpha.

Parameters:
newColorAlpha - new color alpha

setRed

public void setRed(float newRed)
Set red.

Parameters:
newRed - new red value

setGreen

public void setGreen(float newGreen)
Set green.

Parameters:
newGreen - new green value

setBlue

public void setBlue(float newBlue)
Set blue.

Parameters:
newBlue - new blue value

check

public static boolean check(String color)

fromString

public void fromString(String color)

fromStringWithoutAlpha

public void fromStringWithoutAlpha(String color)

randomColor

public static Color randomColor()


Copyright © 2011. All Rights Reserved.