Xj3D VRML/X3D Code API

org.web3d.util
Class ColorUtils

java.lang.Object
  extended byorg.web3d.util.ColorUtils

public class ColorUtils
extends java.lang.Object

An interpolator that works with color components.

The interpolation routine is just a simple linear interpolation between each of the points. The interpolator may take arbitrarily spaced keyframes and compute correct values.

Color interpolation can be done in the standard RGB space (LINEAR) or using the additional type of HSV_LINEAR. This internally converts all color values to HSV space and then interpolates over that instead.

The RGB<->HSV color space conversions have been taken from Foley & van Dam Computer Graphics Principles and Practice, 2nd Edition, Addison Wesley, 1990.

Version:
$Revision: 1.2 $
Author:
Justin Couch

Constructor Summary
ColorUtils()
           
 
Method Summary
static void convertHSVtoRGB(float[] hsv, float[] rgb)
          Change an RGB color to HSV color.
static void convertHSVtoRGB(float h, float s, float v, float[] rgb)
          Change an RGB color to HSV color.
static void convertRGBtoHSV(float[] rgb, float[] hsv)
          Change an RGB color to HSV color.
static void convertRGBtoHSV(float r, float g, float b, float[] hsv)
          Change an RGB color to HSV color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtils

public ColorUtils()
Method Detail

convertRGBtoHSV

public static void convertRGBtoHSV(float[] rgb,
                                   float[] hsv)
Change an RGB color to HSV color. The value is left in the sharedVector array for copying. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
rgb - The array of RGB components to convert
hsv - An array to return the colour values with

convertRGBtoHSV

public static void convertRGBtoHSV(float r,
                                   float g,
                                   float b,
                                   float[] hsv)
Change an RGB color to HSV color. The value is left in the sharedVector array for copying. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
r - The r component of the color at this key
g - The g component of the color at this key
b - The b component of the color at this key
hsv - An array to return the HSV colour values in

convertHSVtoRGB

public static void convertHSVtoRGB(float[] hsv,
                                   float[] rgb)
Change an RGB color to HSV color. The value is left in the sharedVector array for copying. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
hsv - The three components of the color at this key
rgb - An array to return the RGB colour values in

convertHSVtoRGB

public static void convertHSVtoRGB(float h,
                                   float s,
                                   float v,
                                   float[] rgb)
Change an RGB color to HSV color. The value is left in the sharedVector array for copying. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
h - The h component of the color at this key
s - The s component of the color at this key
v - The v component of the color at this key
rgb - An array to return the RGB colour values in

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium