edu.rit.color
Class HSB

java.lang.Object
  extended by edu.rit.color.HSB

public class HSB
extends Object

Class HSB provides a color represented as floating point hue, saturation, and brightness components.

The hue component gives the basic color. A hue of 0 = red; 1/6 = yellow; 2/6 = green; 3/6 = cyan; 4/6 = blue; 5/6 = magenta; 1 = red again. Intermediate hue values yield intermediate colors.

The saturation component specifies how gray or colored the color is. A saturation of 0 yields fully gray; a saturation of 1 yields fully colored. Intermediate saturation values yield mixtures of gray and colored.

The brightness component specifies how dark or light the color is. A brightness of 0 yields fully dark (black); a brightness of 1 yields fully light (somewhere between white and colored depending on the saturation). Intermediate brightness values yield somewhere between a gray shade and a darkened color (depending on the saturation).

Class HSB includes methods for packing and unpacking a floating point HSB color object into and from an integer. The packed color representation uses 8 bits for each component, with the red component in bits 23-16, the green component in bits 15-8, and the blue component in bits 7-0.


Field Summary
 float bri
          The brightness component in the range 0.0 through 1.0.
 float hue
          The hue component in the range 0.0 through 1.0.
 float sat
          The saturation component in the range 0.0 through 1.0.
 
Constructor Summary
HSB()
          Construct a new floating point HSB color.
HSB(float hue, float sat, float bri)
          Construct a new floating point HSB color with the given hue, saturation, and brightness components.
HSB(int color)
          Construct a new floating point HSB color from the given packed color.
 
Method Summary
 int pack()
          Pack this floating point HSB color into a packed color.
static int pack(float hue, float sat, float bri)
          Pack the given hue, saturation, and brightness components into a packed color.
 void unpack(int color)
          Unpack this floating point HSB color from a packed color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hue

public float hue
The hue component in the range 0.0 through 1.0.


sat

public float sat
The saturation component in the range 0.0 through 1.0.


bri

public float bri
The brightness component in the range 0.0 through 1.0.

Constructor Detail

HSB

public HSB()
Construct a new floating point HSB color. The hue, saturation, and brightness components are all 0.


HSB

public HSB(float hue,
           float sat,
           float bri)
Construct a new floating point HSB color with the given hue, saturation, and brightness components.

Parameters:
hue - Hue component.
sat - Saturation component.
bri - Brightness component.

HSB

public HSB(int color)
Construct a new floating point HSB color from the given packed color.

Parameters:
color - Packed color.
Method Detail

pack

public int pack()
Pack this floating point HSB color into a packed color.

Returns:
Packed color.

pack

public static int pack(float hue,
                       float sat,
                       float bri)
Pack the given hue, saturation, and brightness components into a packed color.

Parameters:
hue - Hue component.
sat - Saturation component.
bri - Brightness component.
Returns:
Packed color.

unpack

public void unpack(int color)
Unpack this floating point HSB color from a packed color.

Parameters:
color - Packed color.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.