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]) : ();
45 Imager::Color::Float - Rough floating point sample colour handling
49 $color = Imager::Color->new($red, $green, $blue);
50 $color = Imager::Color->new($red, $green, $blue, $alpha);
51 $color = Imager::Color->new("#C0C0FF"); # html color specification
53 $color->set($red, $green, $blue);
54 $color->set($red, $green, $blue, $alpha);
55 $color->set("#C0C0FF"); # html color specification
57 ($red, $green, $blue, $alpha) = $color->rgba();
58 @hsv = $color->hsv(); # not implemented but proposed
65 This module handles creating color objects used by imager. The idea is
66 that in the future this module will be able to handle colorspace calculations
69 A floating point Imager color consists of up to four components, each
70 in the range 0.0 to 1.0. Unfortunately the meaning of the components
71 can change depending on the type of image you're dealing with:
77 for 3 or 4 channel images the color components are red, green, blue,
82 for 1 or 2 channel images the color components are gray, alpha, with
83 the other two components ignored.
87 An alpha value of zero is fully transparent, an alpha value of 1.0 is
96 This creates a color object to pass to functions that need a color argument.
100 This changes an already defined color. Note that this does not affect any places
101 where the color has been used previously.
105 This returns the rgba code of the color the object contains.
109 Calling info merely dumps the relevant colorcode to the log.
115 Arnar M. Hrafnkelsson, addi@umich.edu
116 And a great deal of help from others - see the README for a complete
121 Imager(3), Imager::Color.
123 http://imager.perl.org/