Graphics::Toolkit::Color::Name(3)

NAME
Graphics::Toolkit::Color::Name - translate color names to values and vice versa

SYNOPSIS
    use Graphics::Toolkit::Color::Name;
    my @names = Graphics::Toolkit::Color::Name::all('HTML', 'default');
    my $values = Graphics::Toolkit::Color::Name::get_values('green');
    my $values = Graphics::Toolkit::Color::Name::get_values('green', [qw/SVG X/]);
    my $name = Graphics::Toolkit::Color::Name::from_values([0, 128, 0]);
    my $name = Graphics::Toolkit::Color::Name::from_values([0, 128, 0], 'HTML');
    my ($name, $distance) = Graphics::Toolkit::Color::Name::closest_from_values(
                                [0, 128, 0], [qw/CSS Pantone/], 'all');

    Graphics::Toolkit::Color::Name::add_scheme( $scheme, 'custom' );

DESCRIPTION
This module autoloads and holds a set of color schemes, where color names with associated RGB values are stored (color name spaces). There is a default scheme and additional ones, fed Graphics::ColorNames::* Modules. which have to be installed separately. For your convenance I created Bundle::Graphics::ColorNames to install them all at once, which all also frees you from the search which module provides which space (some provide several).

This module also provides methods that search in those schemes. Wherever a method accepts a color scheme name, it will default to the default name space, but also accepts an ARRAY with several scheme names.

SCHEMES
Acceptable scheme names are currently: Crayola, CSS, EmergyC, GrayScale, HTML, IE, Mozilla, Netscape, Pantone, PantoneReport, SVG, VACCC, Werner, Windows, WWW or X (X11).

ROUTINES

  all
Returns a list of color names constants of the default schema. All arguments are interpreted as scheme names. If provided, the method hows only the names from these schemes.

  get_values
.. accepts two arguments. The first one is required and is a color name. The result will be the RGB value tuple (ARRAY) of this color.

Optionally you may provide a second argument, which is a color scheme name - if none is provided, the default scheme is used. Please note this is the only routine in this lib where you can provide only one scheme.

  from_values
This method works the other way around as the previous one. It takes am RGB value tuple and returns a color name if possible. If no stored color has the exact same values, an empty string is the result.

The search is limited to the default color scheme, unless a name of another scheme or several of them in an ARRAY are provided as second argument.

If the provided values belong to several color names only the first one is returned, which is in many cases the most popular. If you provide the third positional argument with a positive pseudo boolean, you will get all found color names.

  closest_from_values
this method gets the same parameter and works almost the same way, as the previous method. The big difference: the search is not for an exact match but the closest one (Euclidean distance). This way you are guaranteed to get one or several names in return. These names have to be delivered inside a ARRAY ref, because there is a second return value, the distance between the provided values and the found color

SEE ALSO
Color::Library

Graphics::ColorNamesLite::All

COPYRIGHT & LICENSE
Copyright 2025-26 Herbert Breunung.

This program is free software; you can redistribute it and/or modify it under same terms as Perl itself.

AUTHOR
Herbert Breunung, <lichtkind@cpan.org>