edu.rit.color
Class RGB

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

public class RGB
extends Object

Class RGB provides a color represented as floating point red, green, and blue components.

Class RGB includes methods for packing and unpacking a floating point RGB 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 blue
          The blue component in the range 0.0 through 1.0.
 float green
          The green component in the range 0.0 through 1.0.
 float red
          The red component in the range 0.0 through 1.0.
 
Constructor Summary
RGB()
          Construct a new floating point RGB color.
RGB(float red, float green, float blue)
          Construct a new floating point RGB color with the given red, green, and blue components.
RGB(int color)
          Construct a new floating point RGB color from the given packed color.
 
Method Summary
 int pack()
          Pack this floating point RGB color into a packed color.
static int pack(float red, float green, float blue)
          Pack the given red, green, and blue components into a packed color.
 void unpack(int color)
          Unpack this floating point RGB 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

red

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


green

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


blue

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

Constructor Detail

RGB

public RGB()
Construct a new floating point RGB color. The red, green, and blue components are all 0.


RGB

public RGB(float red,
           float green,
           float blue)
Construct a new floating point RGB color with the given red, green, and blue components.

Parameters:
red - Red component.
green - Green component.
blue - Blue component.

RGB

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

Parameters:
color - Packed color.
Method Detail

pack

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

Returns:
Packed color.

pack

public static int pack(float red,
                       float green,
                       float blue)
Pack the given red, green, and blue components into a packed color.

Parameters:
red - Red component.
green - Green component.
blue - Blue component.
Returns:
Packed color.

unpack

public void unpack(int color)
Unpack this floating point RGB 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.