METHODS

Returns the id of the color A color id is in the format of <dictionary_id:color_name>, e.g.

    svg:aliceblue
    x11:bisque2
    nbs-iscc-f:chromeyellow.66
    vaccc:darkspringyellow

Returns the name of the color, e.g. aliceblue bisque2 chromeyellow darkspringyellow Returns the title of the color, e.g. aliceblue bisque2 chrome yellow Dark Spring-Yellow Returns the Color::Library::Dictionary object that the color belongs to Returns the hex value of the color, e.g. ff08ff eed5b7 eaa221 669900 Note that $hex does \s-1NOT\s0 include the leading #, for that use $color->html, $color->css, or $color->svg Returns the hex value of the color with a leading #, suitable for use in \s-1HTML\s0, \s-1CSS\s0, or \s-1SVG\s0 documents, e.g. #ff08ff #eed5b7 #eaa221 #669900 Returns the numeric value of the color, e.g. 15792383 15652279 15376929 6723840 Returns r, g, and b values of the color as a 3 element list (list context), e.g. (240, 248, 255) Returns r, g, and b values of the color in a 3 element array (scalar context), e.g. [ 240, 248, 255 ] Returns a new Color::Library::Color object representing the specified color You probably don't want/need to call this yourself

\s-1FUNCTIONS\s0

Converts an rgb value to its hex representation Converts an rgb value to its numeric representation Converts a numeric color value to its rgb representation Makes a best effort to convert a hex or numeric color value to its rgb representation

# Partly taken from Imager/Color.pm sub parse_rgb_color {

    return (@_) if @_ == 3 && ! grep /[^\d.+eE-]/, @_;
    if ($_[0] =~ /^\#?([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])$/i) {
        return (hex($1), hex($2), hex($3));
    }
    if ($_[0] =~ /^\#?([\da-f])([\da-f])([\da-f])$/i) {
        return (hex($1) * 17, hex($2) * 17, hex($3) * 17);
    }
    return value2rgb $_[0] if 1 == @_ && $_[0] =~ m/^\d+$/;

}

1;

_\|_END_\|_

sub parse_rgbs_color {

    return (@_) if @_ == 3 && ! grep /[^\d.+eE-]/, @_;
    if ($_[0] =~ /^\#?([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/i) {
        return (hex($1), hex($2), hex($3), hex($4));
    }
    if ($_[0] =~ /^\#?([\da-f][\da-f])([\da-f][\da-f])([\da-f][\da-f])/i) {
        return (hex($1), hex($2), hex($3), 255);
    }
    if ($_[0] =~ /^\#([\da-f])([\da-f])([\da-f])$/i) {
        return (hex($1) * 17, hex($2) * 17, hex($3) * 17, 255);
    }
    return value2rgb $_[0] if 1 == @_;

}