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 $color = Convert::Color::HSV->new( $hue, $saturation, $value )
47 Returns a new object to represent the set of values given. The hue
48 should be in the range 0 to 360 (exclusive), and saturation and value
49 should be between 0 and 1. Values outside of these ranges will be
50 clamped.
51
52 $color = Convert::Color::HSV->new( $string )
53 Parses $string for values, and construct a new object similar to the
54 above three-argument form. The string should be in the form
55
56 hue,saturation,value
57
58 containing the three floating-point values in decimal notation.
59
61 $h = $color->hue
62 $s = $color->saturation
63 $v = $color->value
64 Accessors for the three components of the color.
65
66 $c = $color->chroma
67 Returns the derived property of "chroma", which maps the color space
68 onto a cone instead of a cylinder. This more closely measures the
69 intuitive concept of how "colorful" the color is than the saturation
70 value and is useful for distance calculations.
71
72 ( $hue, $saturation, $value ) = $color->hsv
73 Returns the individual hue, saturation and value components of the
74 color value.
75
76 $measure = $color->dst_hsv( $other )
77 Returns a measure of the distance between the two colors. This is the
78 Euclidean distance between the two colors as points in the chroma-
79 adjusted cone space.
80
81 $measure = $color->dst_hsv_cheap( $other )
82 Returns a measure of the distance between the two colors. This is used
83 in the calculation of "dst_hsv" but since it omits the final square-
84 root and scaling it is cheaper to calculate, for use in cases where
85 only the relative values matter, such as when picking the "best match"
86 out of a set of colors. It ranges between 0 for identical colors and 4
87 for the distance between complementary pure-saturated colors.
88
90 • Convert::Color - color space conversions
91
92 • Convert::Color::RGB - a color value represented as red/green/blue
93
94 • <http://en.wikipedia.org/wiki/HSL_and_HSV> - HSL and HSV on
95 Wikipedia
96
98 Paul Evans <leonerd@leonerd.org.uk>
99
100
101
102perl v5.34.0 2021-07-22 Convert::Color::HSV(3)