Class ColorOps

java.lang.Object
  extended by ColorOps

public class ColorOps
extends java.lang.Object

A noninstantiable utility class to manipulate Color objects.


Constructor Summary
ColorOps()
           
 
Method Summary
static java.awt.Color darken(java.awt.Color c)
          return a darker version of the given Color
static java.awt.Color getBrightColor()
          Return a bright, saturated Color with a random hue
static java.awt.Color getBrightColor(double d)
          Return a bright, saturated Color with a hue based on d
static java.awt.Color interpolate(java.awt.Color c1, java.awt.Color c2, float n)
          Linearly interpolates between two colors based on n.
static java.awt.Color lighten(java.awt.Color c)
          return a lighter version of the given Color
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorOps

public ColorOps()
Method Detail

darken

public static java.awt.Color darken(java.awt.Color c)
return a darker version of the given Color

Parameters:
c - the Color to darken
Returns:
the darker Color

lighten

public static java.awt.Color lighten(java.awt.Color c)
return a lighter version of the given Color

Parameters:
c - the Color to lighten
Returns:
the lighter Color

interpolate

public static java.awt.Color interpolate(java.awt.Color c1,
                                         java.awt.Color c2,
                                         float n)
Linearly interpolates between two colors based on n. If n is 0, this returns a Color equal to c2. If n is 1, you get c1 instead. A c value of .5 will return the average, and so forth.

Parameters:
c1 - the first Color
c2 - the second Color
n - the ratio of c2 to use
Returns:
the interpolated color.

getBrightColor

public static java.awt.Color getBrightColor()
Return a bright, saturated Color with a random hue

Returns:
a bright, saturated Color

getBrightColor

public static java.awt.Color getBrightColor(double d)
Return a bright, saturated Color with a hue based on d

Parameters:
d - the location along the rainbow to choose
Returns:
the specified bright, saturated Color