Manual Reference Pages - COLOR::PALETTE (3)
Color::Palette - a set of named colors
The libraries in the Color-Palette distribution are meant to make it easy to
build sets of named colors, and to write applications that can define and
validate the color names they required.
For example, a color palette might contain the following data:
highlights => #f0f000
background => #333
sidebarBackground => #88d
sidebarText => highlights
sidebarBoder => sidebarText
Colors can be defined by a color specifier (a Graphics::Color object,
a CSS-style hex triple, or an arrayref of RGB values) or by a name of another
color that appears in the palette. If colors are defined in terms of another
color that doesnt exist, an exception will be raised.
Applications that wish to use color palettes can provide schemas that define
the names they expect to be present in a palette. These schemas are
A palette can be checked against a schema with the schemas check method, or
may be reduced to the minimal set of colors needed to satisfy the schema with
the palettes optimized_for method.
This attribute is a hashref. Keys are color names and values are either Color
objects or names of other colors. To get at the color object for a name
consult the "color" method.
my $color_obj = $palette->color(extremeHighlight);
This method will return the Color object to be used for the given name.
my @names = $palette->color_names;
This method returns a list of all color names the object knows about.
my $triple_for = $palette->as_css_hash
This method returns a hashref. Every color name known to the palette has an
entry, and the value is the CSS-safe hex string for the resolved color. For
example, the output for the color scheme in the DESCRIPTION section would
highlights => #f0f000,
background => #333333,
sidebarBackground => #8888dd,
sidebarText => #f0f000,
sidebarBoder => #f0f000,
my $hashref = $palette->as_strict_css_hash;
This method behaves just like "as_css_hash", but the returned hashref is
tied so that trying to read values for keys that do not exist is fatal. The
hash may also become read-only in the future.
my $optimized_palette = $palette->optimized_for($schema);
This method returns a new palette containing only the colors needed to fulfill
the requirements of the given schema. This is useful for reducing a large
palette to the small set that must be embedded in a document.
optimize_for redispatches to this method for historical reasons.
Ricardo SIGNES <firstname.lastname@example.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
|perl v5.20.3 ||COLOR::PALETTE (3) ||2011-12-19 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.