com.threerings.media.image
Class Colorization

java.lang.Object
  extended by com.threerings.media.image.Colorization

public class Colorization
extends Object

Used to support recoloring images.


Field Summary
protected  int[] _fhsv
          Fixed HSV values for our root color; used when calculating recolorizations using this colorization.
protected  float[] _hsv
          HSV values for our root color; used when calculating recolorizations using this colorization.
 int colorizationId
          Every colorization must have a unique id that can be used to compare a particular colorization record with another.
 float[] offsets
          The adjustments to make to hue, saturation and value.
 float[] range
          The range around the root color that will be colorized (in delta-hue, delta-saturation, delta-value.
 Color rootColor
          The root color for the colorization.
 
Constructor Summary
Colorization(int colorizationId, Color rootColor, float[] range, float[] offsets)
          Constructs a colorization record with the specified identifier.
 
Method Summary
static int distance(int a, int b, int N)
          Returns the distance between the supplied to numbers modulo N.
 boolean equals(Object other)
           
 Color getColorizedRoot()
          Returns the root color adjusted by the colorization.
 int hashCode()
           
 boolean matches(float[] hsv, int[] fhsv)
          Returns true if this colorization matches the supplied color, false otherwise.
 int recolorColor(float[] hsv)
          Adjusts the supplied color by the offsets in this colorization, taking the appropriate measures for hue (wrapping it around) and saturation and value (clipping).
static int[] toFixedHSV(float[] hsv, int[] fhsv)
          Converts floating point HSV values to a fixed point integer representation.
 String toString()
           
 String toVerboseString()
          Returns a long string representation of this colorization.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

colorizationId

public int colorizationId
Every colorization must have a unique id that can be used to compare a particular colorization record with another.


rootColor

public Color rootColor
The root color for the colorization.


range

public float[] range
The range around the root color that will be colorized (in delta-hue, delta-saturation, delta-value. Note that this is inclusive.


offsets

public float[] offsets
The adjustments to make to hue, saturation and value.


_fhsv

protected int[] _fhsv
Fixed HSV values for our root color; used when calculating recolorizations using this colorization.


_hsv

protected float[] _hsv
HSV values for our root color; used when calculating recolorizations using this colorization.

Constructor Detail

Colorization

public Colorization(int colorizationId,
                    Color rootColor,
                    float[] range,
                    float[] offsets)
Constructs a colorization record with the specified identifier.

Method Detail

getColorizedRoot

public Color getColorizedRoot()
Returns the root color adjusted by the colorization.


recolorColor

public int recolorColor(float[] hsv)
Adjusts the supplied color by the offsets in this colorization, taking the appropriate measures for hue (wrapping it around) and saturation and value (clipping).

Returns:
the RGB value of the recolored color.

matches

public boolean matches(float[] hsv,
                       int[] fhsv)
Returns true if this colorization matches the supplied color, false otherwise.

Parameters:
hsv - the HSV values for the color in question.
fhsv - the HSV values converted to fixed point via toFixedHSV(float[], int[]) for the color in question.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

toVerboseString

public String toVerboseString()
Returns a long string representation of this colorization.


toFixedHSV

public static int[] toFixedHSV(float[] hsv,
                               int[] fhsv)
Converts floating point HSV values to a fixed point integer representation.

Parameters:
hsv - the HSV values to be converted.
fhsv - the destination array into which the fixed values will be stored. If this is null, a new array will be created of the appropriate length.
Returns:
the fhsv parameter if it was non-null or the newly created target array.

distance

public static int distance(int a,
                           int b,
                           int N)
Returns the distance between the supplied to numbers modulo N.