edu.rit.color
Class IntRGB
- java.lang.Object
-
- edu.rit.color.IntRGB
-
public class IntRGB extends java.lang.ObjectClass IntRGB provides a color represented as integer red, green, and blue components.Class IntRGB includes methods for packing and unpacking an integer 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 intblueThe blue component in the range 0 through 255.intgreenThe green component in the range 0 through 255.intredThe red component in the range 0 through 255.
-
Constructor Summary
Constructors Constructor and Description IntRGB()Construct a new integer RGB color.IntRGB(int color)Construct a new integer RGB color from the given packed color.IntRGB(int red, int green, int blue)Construct a new integer RGB color with the given red, green, and blue components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intpack()Pack this integer RGB color into a packed color.static intpack(int red, int green, int blue)Pack the given red, green, and blue components into a packed color.voidunpack(int color)Unpack this integer RGB color from a packed color.
-
-
-
Field Detail
-
red
public int red
The red component in the range 0 through 255.
-
green
public int green
The green component in the range 0 through 255.
-
blue
public int blue
The blue component in the range 0 through 255.
-
-
Constructor Detail
-
IntRGB
public IntRGB()
Construct a new integer RGB color. The red, green, and blue components are all 0.
-
IntRGB
public IntRGB(int red, int green, int blue)Construct a new integer RGB color with the given red, green, and blue components.- Parameters:
red- Red component.green- Green component.blue- Blue component.
-
IntRGB
public IntRGB(int color)
Construct a new integer RGB color from the given packed color.- Parameters:
color- Packed color.
-
-
Method Detail
-
pack
public int pack()
Pack this integer RGB color into a packed color.- Returns:
- Packed color.
-
pack
public static int pack(int red, int green, int 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 integer RGB color from a packed color.- Parameters:
color- Packed color.
-
-
DMelt 3.0 © DataMelt by jWork.ORG