1 package Imager::Color::Float;
9 # It's just a front end to the XS creation functions.
12 # Parse color spec into an a set of 4 colors
15 return (@_,1) if @_ == 3;
16 return (@_ ) if @_ == 4;
18 /^\#?([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/i) {
19 return (hex($1)/255.99,hex($2)/255.99,hex($3)/255.99,hex($4)/255.99);
21 if ($_[0] =~ /^\#?([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/i) {
22 return (hex($1)/255.99,hex($2)/255.99,hex($3)/255.99,1);
28 shift; # get rid of class name.
30 return @arg ? new_internal($arg[0],$arg[1],$arg[2],$arg[3]) : ();
36 return @arg ? set_internal($self, $arg[0],$arg[1],$arg[2],$arg[3]) : ();
47 Imager::Color::Float - Rough floating point sample color handling
51 $color = Imager::Color->new($red, $green, $blue);
52 $color = Imager::Color->new($red, $green, $blue, $alpha);
53 $color = Imager::Color->new("#C0C0FF"); # html color specification
55 $color->set($red, $green, $blue);
56 $color->set($red, $green, $blue, $alpha);
57 $color->set("#C0C0FF"); # html color specification
59 ($red, $green, $blue, $alpha) = $color->rgba();
60 @hsv = $color->hsv(); # not implemented but proposed
67 This module handles creating color objects used by Imager. The idea
68 is that in the future this module will be able to handle color space
71 A floating point Imager color consists of up to four components, each
72 in the range 0.0 to 1.0. Unfortunately the meaning of the components
73 can change depending on the type of image you're dealing with:
79 for 3 or 4 channel images the color components are red, green, blue,
84 for 1 or 2 channel images the color components are gray, alpha, with
85 the other two components ignored.
89 An alpha value of zero is fully transparent, an alpha value of 1.0 is
98 This creates a color object to pass to functions that need a color argument.
102 This changes an already defined color. Note that this does not affect any places
103 where the color has been used previously.
107 This returns the red, green, blue and alpha channels of the color the
112 Calling info merely dumps the relevant color to the log.
118 Arnar M. Hrafnkelsson, addi@umich.edu
119 And a great deal of help from others - see the C<README> for a complete
124 Imager(3), Imager::Color.
126 http://imager.perl.org/