NAME
Data::Displaycolour - Work with display colours
VERSION
version v0.01
SYNOPSIS
use Data::Displaycolour;
my Data::Displaycolour $dp = Data::Displaycolour->new(...);
say $dp->rgb;
This module supports working with display colours for arbitrary subjects.
Note: This package is still a bit experimental. While the API should be stable for use, the results may change over the next releases as palette and matching code updates will take place.
This package inherits from Data::Identifier::Interface::Userdata, and Data::Identifier::Interface::Subobjects, and Data::Identifier::Interface::Known.
METHODS
new
my Data::Displaycolour $dc = Data::Displaycolour->new(%opts);
Creates a new displaycolour object.
The following options are supported:
for
-
A blessed reference that represents the object we want the display colour for. This might be anything "lookup" in Data::URIID accepts as input. (If it is a URI it must be a URI object or similar.)
for_displayname
-
A displayname for which a colour should be found.
for_email
-
An e-mail address (without the name) for which a colour should be found.
for_name
-
An name (such as a legal name) for which a colour should be found.
for_text
-
Some portion of text (normally one sentence to a full paragraph) for which a colour should be found.
for_username
-
Some username for which a colour should be found.
from
-
A colour value this object should be constructed from. This might be anything "new" in Data::URIID::Colour accespts via
from
. Please also keep the notes in the documentation for that method in mind. palette
-
The palette to use. If this is a scalar it is the name of the palette. If an array reference it must be a list of
#rrggbb
values. In this case default values are used for abstract colours. Other types of values might be supported. Newer versions of this module might support more palette types. subobjects
-
A unblessed hashref that is passed to L<Data::Identifier::Interface::Subobjects/so_attach>.
origin
my Data::URIID::Colour $origin = $dc->origin;
# or:
my $origin = $dc->origin($as [, %opts ] );
Returns the origin colour of this object. This value might be an abstract or specific colour and might or might not be set.
If there is any problem or error this method die
s.
$as
is to be understood the same way as in "as" in Data::Identifier. If not given, Data::URIID::Colour is assumed.
The following options are supported:
default
-
The default value to return if no value is known. When set to
undef
this can be used to switch this method to returningundef
(notdie
) in case no value is known. no_defaults
-
If a true value disables looking up a value based on other values.
abstract
my $abstract = $dc->abstract( [ $as [, %opst] ] );
This method returns the abstract colour. It works the same as "origin" and takes the same arguments.
specific
my $specific = $dc->specific( [ $as [, %opst] ] );
This method returns the specific colour. It works the same as "origin" and takes the same arguments.
rgb
my $rgb = $dc->rgb( [ %opts ] );
Returns a single RGB value as per "rgb" in Data::URIID::Colour.
Takes the same options as "origin".
list_colours
my $colours = Data::Displaycolour->list_colours($palette_name);
Returns a hashref with the keys being RGB (#rrggbb
) colour values of all colours present in the palette (fallbacks are not listed). The values are a Data::Identifier of the abstract colour this value represents (if any) or undef
.
For discovery of known palettes see "known".
known
my @list = Data::Displaycolour->known($class [, %opts ] );
Returns a list of well known items. See "known" in Data::Identifier::Interface::Known for details.
The following classes are supported:
abstract-colours
-
The list of abstract colours known by this module.
palettes
-
The list of palettes known by this module. See "new".
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)