1Convert::Color::HSV(3)User Contributed Perl DocumentationConvert::Color::HSV(3)
2
3
4
6 "Convert::Color::HSV" - a color value represented as
7 hue/saturation/value
8
10 Directly:
11
12 use Convert::Color::HSV;
13
14 my $red = Convert::Color::HSV->new( 0, 1, 1 );
15
16 # Can also parse strings
17 my $pink = Convert::Color::HSV->new( '0,0.7,1' );
18
19 Via Convert::Color:
20
21 use Convert::Color;
22
23 my $cyan = Convert::Color->new( 'hsv:300,1,1' );
24
26 Objects in this class represent a color in HSV space, as a set of three
27 floating-point values. Hue is stored as a value in degrees, in the
28 range 0 to 360 (exclusive). Saturation and value are in the range 0 to
29 1.
30
31 This color space may be considered as a cylinder, of height and radius
32 1. Hue represents the position of the color as the angle around the
33 axis, the saturation the distance from the axis, and the value the
34 height above the base. In this shape, the entire base of the cylinder
35 is pure black, the axis through the centre represents the range of
36 greys, and the circumference of the top of the cylinder contains the
37 pure-saturated color wheel, with a pure white point at its centre.
38
39 Because the entire bottom surface of this cylinder contains black, a
40 closely-related color space can be created by reshaping the cylinder
41 into a cone by contracting the base of the cylinder into a point. The
42 radius from the axis is called the chroma (though this is a different
43 definition of "chroma" than that used by CIE).
44
46 new
47 $color = Convert::Color::HSV->new( $hue, $saturation, $value )
48
49 Returns a new object to represent the set of values given. The hue
50 should be in the range 0 to 360 (exclusive), and saturation and value
51 should be between 0 and 1. Values outside of these ranges will be
52 clamped.
53
54 $color = Convert::Color::HSV->new( $string )
55
56 Parses $string for values, and construct a new object similar to the
57 above three-argument form. The string should be in the form
58
59 hue,saturation,value
60
61 containing the three floating-point values in decimal notation.
62
64 hue
65 $h = $color->hue
66
67 saturation
68 $s = $color->saturation
69
70 value
71 $v = $color->value
72
73 Accessors for the three components of the color.
74
75 chroma
76 $c = $color->chroma
77
78 Returns the derived property of "chroma", which maps the color space
79 onto a cone instead of a cylinder. This more closely measures the
80 intuitive concept of how "colorful" the color is than the saturation
81 value and is useful for distance calculations.
82
83 hsv
84 ( $hue, $saturation, $value ) = $color->hsv
85
86 Returns the individual hue, saturation and value components of the
87 color value.
88
89 dst_hsv
90 $measure = $color->dst_hsv( $other )
91
92 Returns a measure of the distance between the two colors. This is the
93 Euclidean distance between the two colors as points in the chroma-
94 adjusted cone space.
95
96 dst_hsv_cheap
97 $measure = $color->dst_hsv_cheap( $other )
98
99 Returns a measure of the distance between the two colors. This is used
100 in the calculation of "dst_hsv" but since it omits the final square-
101 root and scaling it is cheaper to calculate, for use in cases where
102 only the relative values matter, such as when picking the "best match"
103 out of a set of colors. It ranges between 0 for identical colors and 4
104 for the distance between complementary pure-saturated colors.
105
107 • Convert::Color - color space conversions
108
109 • Convert::Color::RGB - a color value represented as red/green/blue
110
111 • <http://en.wikipedia.org/wiki/HSL_and_HSV> - HSL and HSV on
112 Wikipedia
113
115 Paul Evans <leonerd@leonerd.org.uk>
116
117
118
119perl v5.34.1 2022-05-10 Convert::Color::HSV(3)