textbender.o.awt
Class ColorX

java.lang.Object
  extended by ColorX

public class ColorX
extends Object

Color utilities.


Field Summary
static Color TRANSPARENT
          The entirely transparent colour, in the default sRGB space.
 
Method Summary
static float brightness(Color color)
          Returns the brightness of the color, per the HSB model.
static float hue(Color color)
          Returns the hue of the color, per the HSB model.
static Color interBright(Color c0, float b1, float fraction)
          Creates a colour intermediate between two other colours with respect to brightness.
static Color interColor(Color c0, Color c1, float fraction)
          Creates a colour intermediate between two other colours.
static Color interHued(Color c0, float h1, float fraction)
          Creates a colour intermediate between two other colours with respect to hue.
static Color interSaturated(Color c0, float s1, float fraction)
          Creates a colour intermediate between two other colours with respect to saturation.
static Color offBright(Color color, float fraction)
          Returns a darker or brighter shade of the colour.
static Color offBright(Color color, float fraction, boolean isDark)
          Returns a darker or brighter shade of the colour.
static float saturation(Color color)
          Returns the saturation of the color, per the HSB model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSPARENT

public static final Color TRANSPARENT
The entirely transparent colour, in the default sRGB space.

Method Detail

brightness

public static float brightness(Color color)
Returns the brightness of the color, per the HSB model.


hue

public static float hue(Color color)
Returns the hue of the color, per the HSB model.


interBright

public static Color interBright(Color c0,
                                float b1,
                                float fraction)
Creates a colour intermediate between two other colours with respect to brightness.

Parameters:
c0 - first colour
b1 - brightness of second colour
fraction - along line from brightness of c0, to b1; where 0.0 (or less) returns c0, and 1.0 (or more) returns c0 with brightness b1, and anything in between returns a proportionately intermediate brightness

interColor

public static Color interColor(Color c0,
                               Color c1,
                               float fraction)
Creates a colour intermediate between two other colours.

Parameters:
c0 - first colour
c1 - second colour
fraction - along line from c0 to c1; where 0.0 (or less) returns c0, and 1.0 (or more) returns c1, and anything in between returns a proportionately intermediate colour

interHued

public static Color interHued(Color c0,
                              float h1,
                              float fraction)
Creates a colour intermediate between two other colours with respect to hue.

Parameters:
c0 - first colour
h1 - hue of second colour
fraction - along line from hue of c0, to h1; where 0.0 (or less) returns c0, and 1.0 (or more) returns c0 with hue h1, and anything in between returns a proportionately intermediate hue

interSaturated

public static Color interSaturated(Color c0,
                                   float s1,
                                   float fraction)
Creates a colour intermediate between two other colours with respect to saturation.

Parameters:
c0 - first colour
s1 - saturation of second colour
fraction - along line from saturation of c0, to s1; where 0.0 (or less) returns c0, and 1.0 (or more) returns c0 with saturation s1, and anything in between returns a proportionately intermediate saturation

offBright

public static Color offBright(Color color,
                              float fraction)
Returns a darker or brighter shade of the colour. Same as:
     offBright( color, fraction, brightness(color) < 0.7f )
     


offBright

public static Color offBright(Color color,
                              float fraction,
                              boolean isDark)
Returns a darker or brighter shade of the colour.

Parameters:
fraction - to shade; where 0.0 (or less) returns the same (or equal) colour; and 1.0 (or more) returns the shade having the most extreme contrast; and intermediate values return intermediate shades
isDark - whether or not you consider the colour dark

saturation

public static float saturation(Color color)
Returns the saturation of the color, per the HSB model.