|o||Convert::Color::RGB - red/green/blue as floats between 0 and 1|
|o||Convert::Color::RGB8 - red/green/blue as 8-bit integers|
|o||Convert::Color::RGB16 - red/green/blue as 16-bit integers|
|o||Convert::Color::HSV - hue/saturation/value|
|o||Convert::Color::HSL - hue/saturation/lightness|
|o||Convert::Color::CMY - cyan/magenta/yellow|
|o||Convert::Color::CMYK - cyan/magenta/yellow/key (blackness)|
|o||Convert::Color::VGA - named lookup for the basic VGA colors|
|o||Convert::Color::X11 - named lookup of colors from X11s rgb.txt|
CW$color = Convert::Color->new( STRING )Return a new value to represent the color specified by the string. This string should be prefixed by the name of the color space to which it applies. For example
rgb:RED,GREEN,BLUE rgb8:RRGGBB rgb16:RRRRGGGGBBBB hsv:HUE,SAT,VAL hsl:HUE,SAT,LUM cmy:CYAN,MAGENTA,YELLOW cmyk:CYAN,MAGENTA,YELLOW,KEY vga:NAME vga:INDEX x11:NAME
For more detail, see the constructor of the color space subclass in question.
( CW$red, CW$green, CW$blue ) = CW$color->rgbReturns the individual red, green and blue color components of the color value. For RGB values, this is done directly. For values in other spaces, this is done by first converting them to an RGB value using their to_rgb() method.
Cross-conversion between color spaces is provided by the convert_to() method, assisted by helper methods in the two color space classes involved.
When converting $color from color space SRC to color space DEST, the following operations are attemped, in this order. SRC and DEST refer to the names of the color spaces, e.g. rgb.
These functions may be called in the following ways:
1. If SRC and DEST are equal, return $color as it stands. 2. If the SRC spaces class provides a convert_to_DEST method, use it. 3. If the DEST spaces class provides a new_from_SRC constructor, call it and pass $color. 4. If the DEST spaces class provides a new_rgb constructor, convert $color to red/green/blue components then call it. 5. If none of these operations worked, then throw an exception.
$other = $color->convert_to_DEST() $other = Dest::Class->new_from_SRC( $color ) $other = Dest::Class->new_rgb( $color->rgb )
CW$other = CW$color->convert_to( CW$space )Attempt to convert the color into its representation in the given space. See above for the various ways this may be achieved.
If the relevant subclass has already been loaded (either explicitly, or implicitly by either the new or convert_to methods), then a specific conversion method will be installed in the class.
$other = $color->as_$space
This class provides AUTOLOAD and can behaviour which automatically constructs conversion methods. The following method calls are identical:
The generated method will be stored in the package, so that future calls will not have the AUTOLOAD overhead.
This feature is deprecated and should not be relied upon, due to the delicate nature of AUTOLOAD.
As well as the above, it is likely the subclass will provide accessors to directly obtain the components of its representation in the specific space. For more detail, see the documentation for the specific subclass in question.
This base class is intended to be subclassed to provide more color spaces.
CW$class->register_color_space( CW$space )A subclass should call this method to register itself as a named color space.
CW$class->register_palette( CW%args )A subclass that provides a fixed set of color values should call this method, to set up automatic conversions that look for the closest match within the set. This conversion process is controlled by the %args:
This method creates a new class method on the calling package, called closest_to.
enumerate => STRING or CODE A method name or anonymous CODE reference which will be used to generate the list of color values. enumerate_once => STRING or CODE As per enumerate, but will be called only once and the results cached.
$color = $pkg->closest_to( $orig, $space )
Returns the color in the space closest to the given value. The distance is measured in the named space; defaulting to rgb if this is not provided.
In the case of a tie, where two or more colors have the same distance from the target, the first one will be chosen.
Paul Evans <firstname.lastname@example.org>
|perl v5.20.3||CONVERT::COLOR (3)||2014-06-01|