1Imager::Color::Float(3)User Contributed Perl DocumentatioInmager::Color::Float(3)
2
3
4

NAME

6       Imager::Color::Float - Rough floating point sample color handling
7

SYNOPSIS

9         $color = Imager::Color->new($red, $green, $blue);
10         $color = Imager::Color->new($red, $green, $blue, $alpha);
11         $color = Imager::Color->new("#C0C0FF"); # html color specification
12
13         $color->set($red, $green, $blue);
14         $color->set($red, $green, $blue, $alpha);
15         $color->set("#C0C0FF"); # html color specification
16
17         ($red, $green, $blue, $alpha) = $color->rgba();
18         @hsv = $color->hsv(); # not implemented but proposed
19         my $c8 = $color->as_8bit;
20
21         $color->info();
22

DESCRIPTION

24       This module handles creating color objects used by Imager.  The idea is
25       that in the future this module will be able to handle color space
26       calculations as well.
27
28       A floating point Imager color consists of up to four components, each
29       in the range 0.0 to 1.0. Unfortunately the meaning of the components
30       can change depending on the type of image you're dealing with:
31
32       •   for 3 or 4 channel images the color components are red, green,
33           blue, alpha.
34
35       •   for 1 or 2 channel images the color components are gray, alpha,
36           with the other two components ignored.
37
38       An alpha value of zero is fully transparent, an alpha value of 1.0 is
39       fully opaque.
40

METHODS

42       new This creates a color object to pass to functions that need a color
43           argument.
44
45       set This changes an already defined color.  Note that this does not
46           affect any places where the color has been used previously.
47
48       rgba()
49           This returns the red, green, blue and alpha channels of the color
50           the object contains.
51
52       info
53           Calling info merely dumps the relevant color to the log.
54
55       red
56       green
57       blue
58       alpha
59           Returns the respective component as a floating point value
60           typically from 0 to 1.0.
61
62       as_8bit
63           Returns the color as the roughly equivalent 8-bit Imager::Color
64           object.  Samples below zero or above 1.0 are clipped.
65
66       as_css_rgb
67           Formats the color as a CSS rgb() style color.  If the color is
68           closely representable as byte style syntax, eg rgb(255, 128, 128),
69           it will be returned in that form, otherwise the samples are
70           formatted as percentages with up to 2 decimal places.
71
72   Setting colors
73       The new() and set() methods can accept the following parameters:
74
75       •   an Imager::Color::Float object
76
77       •   an Imager::Color object, the ranges of samples are translated from
78           0...255 to 0.0...1.0.
79
80       •   3 values, treated as red, green, blue
81
82       •   4 values, treated as red, green, blue, alpha
83
84       •   an 8 character hex color, optionally preceded by "#".
85
86       •   a 6 character hex color, optionally preceded by "#".
87
88       •   a CSS rgb() color, based on CSS Color 4.  The "none" keyword is not
89           supported and numbers must be simple decimals without exponents.
90           eg.
91
92             rgb(50% 50% 100%)
93             rgb(0, 0, 255)
94             rgb(0.5 0.5 1.0 / 0.8)
95             rgb(50%, 50%, 100%, 80%)
96
97           This accepts some colors not accepted by the CSS rgb()
98           specification, this may change.
99

AUTHOR

101       Arnar M. Hrafnkelsson, addi@umich.edu And a great deal of help from
102       others - see the "README" for a complete list.
103

SEE ALSO

105       Imager(3), Imager::Color.
106
107       http://imager.perl.org/
108
109
110
111perl v5.36.0                      2023-01-20           Imager::Color::Float(3)
Impressum