Class ColorVector

java.lang.Object
  extended by ColorVector

public class ColorVector
extends java.lang.Object

Represents a factor by which to multiply a color's components, including different factors for each component.


Field Summary
static ColorVector ONE
           
static ColorVector ZERO
           
 
Constructor Summary
ColorVector(double r, double g, double b)
          Constructs a color vector with the given component multipliers.
ColorVector(float r, float g, float b)
          Constructs a color vector with the given component multipliers.
 
Method Summary
 ColorVector add(ColorVector other)
          Returns a color vector whose multipliers are the sum of this color's multipliers and the parametere color's multipliers.
 float getBlue()
          Returns the blue color muliplier.
 float getGreen()
          Returns the green color muliplier.
 double getNorm()
          Returns the norm - ie, length - of this color vector.
 float getRed()
          Returns the red color muliplier.
 Color scale(Color other)
          Returns a color whose components have been scaled by this color vector's multipliers.
 ColorVector scale(ColorVector other)
          Returns a color vector whose multipliers are the product of this color's multipliers and the parameter color's multipliers.
 ColorVector scale(double scalar)
          Returns a color vector whose multipliers are all scaled by the given scalar.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final ColorVector ZERO

ONE

public static final ColorVector ONE
Constructor Detail

ColorVector

public ColorVector(double r,
                   double g,
                   double b)
Constructs a color vector with the given component multipliers.


ColorVector

public ColorVector(float r,
                   float g,
                   float b)
Constructs a color vector with the given component multipliers.

Method Detail

getNorm

public double getNorm()
Returns the norm - ie, length - of this color vector.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRed

public float getRed()
Returns the red color muliplier.


getGreen

public float getGreen()
Returns the green color muliplier.


getBlue

public float getBlue()
Returns the blue color muliplier.


add

public ColorVector add(ColorVector other)
Returns a color vector whose multipliers are the sum of this color's multipliers and the parametere color's multipliers.


scale

public ColorVector scale(double scalar)
Returns a color vector whose multipliers are all scaled by the given scalar.


scale

public ColorVector scale(ColorVector other)
Returns a color vector whose multipliers are the product of this color's multipliers and the parameter color's multipliers.


scale

public Color scale(Color other)
Returns a color whose components have been scaled by this color vector's multipliers.