1Convert::Color::RGB16(3U)ser Contributed Perl DocumentatiCoonnvert::Color::RGB16(3)
2
3
4

NAME

6       "Convert::Color::RGB16" - a color value represented as red/green/blue
7       in 16-bit integers
8

SYNOPSIS

10       Directly:
11
12          use Convert::Color::RGB16;
13
14          my $red = Convert::Color::RGB16->new( 65535, 0, 0 );
15
16          # Can also parse strings
17          my $pink = Convert::Color::RGB16->new( '65535,49152,49152' );
18
19          # or
20          $pink = Convert::Color::RGB16->new( 'ffffc000c000' );
21
22       Via Convert::Color:
23
24          use Convert::Color;
25
26          my $cyan = Convert::Color->new( 'rgb16:0,65535,65535' );
27

DESCRIPTION

29       Objects in this class represent a color in RGB space, as a set of three
30       integer values in the range 0 to 65535; i.e. as 16 bits.
31
32       For representations using floating point values, see
33       Convert::Color::RGB.  For representations using 8-bit integers, see
34       Convert::Color::RGB8.
35

CONSTRUCTOR

37   new
38          $color = Convert::Color::RGB16->new( $red, $green, $blue )
39
40       Returns a new object to represent the set of values given. These values
41       should be integers between 0 and 65535. Values outside of this range
42       will be clamped.
43
44          $color = Convert::Color::RGB16->new( $string )
45
46       Parses $string for values, and construct a new object similar to the
47       above three-argument form. The string should be in the form
48
49          red,green,blue
50
51       containing the three integer values in decimal notation. It can also be
52       given in the form of a hex encoded string, such as would be returned by
53       the "rgb16_hex" method:
54
55          rrrrggggbbbb
56

METHODS

58   red
59          $r = $color->red
60
61   green
62          $g = $color->green
63
64   blue
65          $b = $color->blue
66
67       Accessors for the three components of the color.
68
69   rgb16
70          ( $red, $green, $blue ) = $color->rgb16
71
72       Returns the individual red, green and blue color components of the
73       color value in RGB16 space.
74
75   hex
76          $str = $color->hex
77
78       Returns a string representation of the color components in the RGB16
79       space, in a convenient "RRRRGGGGBBBB" hex string.
80
81   alpha_blend
82          $mix = $color->alpha_blend( $other, [ $alpha ] )
83
84       Return a new color which is a blended combination of the two passed
85       into it.  The optional $alpha parameter defines the mix ratio between
86       the two colors, defaulting to 0.5 if not defined. Values closer to 0
87       will blend more of $color, closer to 1 will blend more of $other.
88
89   alpha16_blend
90          $mix = $color->alpha16_blend( $other, [ $alpha ] )
91
92       Similar to "alpha_blend" but works with integer arithmetic. $alpha
93       should be an integer in the range 0 to 65535.
94
95   dst_rgb16
96          $measure = $color->dst_rgb16( $other )
97
98       Return a measure of the distance between the two colors. This is the
99       unweighted Euclidean distance of the three color components. Two
100       identical colors will have a measure of 0, pure black and pure white
101       have a distance of 1, and all others will lie somewhere inbetween.
102
103   dst_rgb16_cheap
104          $measure = $color->dst_rgb16_cheap( $other )
105
106       Return a measure of the distance between the two colors. This is the
107       sum of the squares of the differences of each of the color components.
108       This is part of the value used to calculate "dst_rgb16", but since it
109       involves no square root it will be cheaper to calculate, for use in
110       cases where only the relative values matter, such as when picking the
111       "best match" out of a set of colors.  It ranges between 0 for identical
112       colours and 3*(65535^2) for the distance between pure black and pure
113       white.
114

SEE ALSO

116       •   Convert::Color - color space conversions
117

AUTHOR

119       Paul Evans <leonerd@leonerd.org.uk>
120
121
122
123perl v5.34.1                      2022-05-10          Convert::Color::RGB16(3)
Impressum