1Convert::Color::RGB8(3)User Contributed Perl DocumentatioCnonvert::Color::RGB8(3)
2
3
4

NAME

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

SYNOPSIS

10       Directly:
11
12          use Convert::Color::RGB8;
13
14          my $red = Convert::Color::RGB8->new( 255, 0, 0 );
15
16          # Can also parse strings
17          my $pink = Convert::Color::RGB8->new( '255,192,192' );
18
19          # or
20          $pink = Convert::Color::RGB8->new( 'ffc0c0' );
21
22       Via Convert::Color:
23
24          use Convert::Color;
25
26          my $cyan = Convert::Color->new( 'rgb8:0,255,255' );
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 255; i.e. as 8 bits.
31
32       For representations using floating point values, see
33       Convert::Color::RGB.  For representations using 16-bit integers, see
34       Convert::Color::RGB16.
35

CONSTRUCTOR

37   new
38          $color = Convert::Color::RGB8->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 255. Values outside of this range will
42       be clamped.
43
44          $color = Convert::Color::RGB8->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 "rgb8_hex" method:
54
55          rrggbb
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   rgb8
70          ( $red, $green, $blue ) = $color->rgb8
71
72       Returns the individual red, green and blue color components of the
73       color value in RGB8 space.
74
75   hex
76          $str = $color->hex
77
78       Returns a string representation of the color components in the RGB8
79       space, in a convenient "RRGGBB" hex string, likely to be useful HTML,
80       or other similar places.
81
82   alpha_blend
83          $mix = $color->alpha_blend( $other, [ $alpha ] )
84
85       Return a new color which is a blended combination of the two passed
86       into it.  The optional $alpha parameter defines the mix ratio between
87       the two colors, defaulting to 0.5 if not defined. Values closer to 0
88       will blend more of $color, closer to 1 will blend more of $other.
89
90   alpha8_blend
91          $mix = $color->alpha8_blend( $other, [ $alpha ] )
92
93       Similar to "alpha_blend" but works with integer arithmetic. $alpha
94       should be an integer in the range 0 to 255.
95
96   dst_rgb8
97          $measure = $color->dst_rgb8( $other )
98
99       Return a measure of the distance between the two colors. This is the
100       unweighted Euclidean distance of the three color components. Two
101       identical colors will have a measure of 0, pure black and pure white
102       have a distance of 1, and all others will lie somewhere inbetween.
103
104   dst_rgb8_cheap
105          $measure = $color->dst_rgb8_cheap( $other )
106
107       Return a measure of the distance between the two colors. This is the
108       sum of the squares of the differences of each of the color components.
109       This is part of the value used to calculate "dst_rgb8", but since it
110       involves no square root it will be cheaper to calculate, for use in
111       cases where only the relative values matter, such as when picking the
112       "best match" out of a set of colors.  It ranges between 0 for identical
113       colours and 3*(255^2) for the distance between pure black and pure
114       white.
115

SEE ALSO

117       •   Convert::Color - color space conversions
118

AUTHOR

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