edu.rit.color
Class RGB
- java.lang.Object
-
- edu.rit.color.RGB
-
public class RGB extends java.lang.ObjectClass 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
Fields Modifier and Type Field and Description floatblueThe blue component in the range 0.0 through 1.0.floatgreenThe green component in the range 0.0 through 1.0.floatredThe red component in the range 0.0 through 1.0.
-
Constructor Summary
Constructors Constructor and Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intpack()Pack this floating point RGB color into a packed color.static intpack(float red, float green, float blue)Pack the given red, green, and blue components into a packed color.voidunpack(int color)Unpack this floating point RGB color from a packed color.
-
-
-
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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG