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