Color::Palette(3pm)
π Color::Palette π
okay bestie, welcome to Color::Palette β it's a Perl module (you'll see it hanging out in the 3pm manual pages, that's the perl module section, iykyk) and it's literally just... a set of named colors. that's the whole vibe. π
β¨ VERSION β¨
this is version 0.100004, babes. write it down.
π DESCRIPTION π
so the libraries in the Color-Palette distribution exist to make it easy to build sets of named colors, and to write apps that can define and validate the color names they require. it's giving organized. it's giving β¨curatedβ¨.
for example, a color palette might contain the following data:
highlights => #f0f000
background => #333
sidebarBackground => #88d
sidebarText => 'highlights'
sidebarBoder => 'sidebarText'
so how do colors get defined? two ways, bestie:
- by a color specifier β that's a
Graphics::Colorobject, a CSS-style hex triple, or an arrayref of RGB values - or by the name of another color that appears in the palette
and if you define a color in terms of another color that doesn't exist? an exception gets raised. no cap. π
apps that wanna use color palettes can provide schemas that define the names they expect to be present in a palette. those schemas are Color::Palette::Schema objects, periodt.
a palette can be checked against a schema with the schema's check method, or it can be reduced to the minimal set of colors needed to satisfy the schema with the palette's optimized_for method. slay. π
πͺ PERL VERSION πͺ
this library should run on perls released even a long time ago. it should work on any version of perl released in the last five years.
although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. the version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. that's just how it is, babe. π
π ATTRIBUTES π
colors
this attribute is a hashref. the keys are color names and the values are either Color objects or names of other colors. to get at the color object for a name, go consult the color method. she'll hook you up. π«Ά
π METHODS π
color
my $color_obj = $palette->color('extremeHighlight');
this method will return the Color object to be used for the given name. that's it. that's the method. iconic. β
color_names
my @names = $palette->color_names;
this method returns a list of all color names the object knows about. every single one. no gatekeeping. π
as_css_hash
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 be:
{
highlights => '#f0f000',
background => '#333333',
sidebarBackground => #8888dd',
sidebarText => #f0f000',
sidebarBoder => #f0f000',
}
look at her go. resolved and gorgeous. β¨
as_strict_css_hash
my $hashref = $palette->as_strict_css_hash;
this method behaves just like "as_css_hash", BUT β and this is the important part bestie β the returned hashref is tied so that trying to read values for keys that do not exist is fatal. π
also, heads up: the hash may also become read-only in the future. so don't get too attached to writing to it. π
optimized_for
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. super useful for reducing a large palette down to the small set that must be embedded in a document. like a glow-down. a declutter. we love a minimal queen. π
oh and also β "optimize_for" redispatches to this method for historical reasons. the spelling is what it is, don't come for her. π°οΈ
π AUTHOR π
Ricardo SIGNES <cpan@semiotic.systems>
π¦ CONTRIBUTORS π¦
- Karen Etheridge <ether@cpan.org>
- Ricardo Signes <rjbs@semiotic.systems>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2022 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.
and that's the whole page, bestie!! this wasperl v5.36.0, dated2023-01-08, and it's theColor::Palette(3pm)manual. go forth and name your colors, you absolute legend. πβ¨ππ¦πΈπ π«Ά
π¦ where this page comes from
- debian bookworm: libcolor-palette-perl 0.100004-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcolor-palette-perl 0.100004-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcolor-palette-perl 0.100004-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcolor-palette-perl 0.100004-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcolor-palette-perl 0.100004-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms