TOC PREV NEXT INDEX

hsv_to_rgb

Synopsis

convert colors from the hsv color cone to the rgb color cube


module hsv_to_rgb {
float h<NEportLevels={0x2,0x1}>;
float s<NEportLevels={0x2,0x1}>;
float v<NEportLevels={0x2,0x1}>;
float r<NEportLevels={0x1,0x2}>;
float g<NEportLevels={0x1,0x2}>;
float b<NEportLevels={0x1,0x2}>;
method+notify_val+notify_inst method_src = "hsv_to_rgb_proc";
};

Input Ports

h

Float. A value between 0 and 1 specifying hue.

s

A value between 0 and 1 specifying saturation.

v

A value between 0 and 1 specifying value.

Output Ports

r

Float. A value between 0 and 1 specifying red.

g

Float. A value between 0 and 1 specifying green.

b

Float. A value between 0 and 1 specifying blue.

Description

hsv_to_rgb converts from the hue, saturation, and value (hsv) color cone to the red, green, blue (rgb) color cube. The rgb values are not computed until all three inputs are set.

The HSV Color Cone

All values are in the range 0.0 to 1.0.

Hue is determined by the angle around the cone. The table below shows values with the associated hues:

Value

Hue

0.000

red

0.166

yellow

0.333

green

0.500

cyan

0.666

blue

0.833

magenta

Saturation is determined by the distance from the center of the cone to the surface. The center (0.0) has no saturation (for example, white) and the surface (1.0) is fully saturated (for example, red). A middle value (0.5) is partially saturated (for example, pink).

Value is determined by the distance from the top of the cone to the base. The top (0.0) has no value (for example, black) and the base of the cone has full value (for example, white). A middle value (0.5) has partial value (for example, grey).

The RGB Color Cube

All values are in the range 0.0 to 1.0.

The RGB color cube is commonly used in computer graphics, because it corresponds directly to the amplitude of the Red, Green, and Blue video signals that drive most computer monitors.

The cube is aligned along the XYZ axes in 3-space. For convenience, the XYZ axes are renamed RGB. Black is at the origin (0,0,0) of the cube. Points along the each axis range from black to the pure color. Diagonally opposite from the origin (1,1,1) is white. Points inside the cube have different saturations and values.

The following colors are associated with the corresponding RGB values:

Red value

Green value

Blue value

Color

0

0

0

black

1

0

0

red

1

1

0

yellow

0

1

0

green

0

1

1

cyan

0

0

1

blue

1

0

1

magenta

1

1

1

white

File

v/gmod.v

See also related modules

rgb_to_hsv
rgb_or_hsv

TOC PREV NEXT INDEX