Look mom I invented colors

Just released Graphics::Toolkit::Color for the purpose to create computationally harmonic color pallets (2-3 lines max for most needs). It is in fact a chunk out of Chart I needed to reuse in other projects as the Harmonograph. And as you can see in the SEE ALSO section of the POD - I'm aware that there are plenty other modules doing, parts, similar stuff or even more.

The reason you should care nonetheless are (beside having good error messages, being well tested, documented and maintained and having almost no dependencies) are II (in words two).

1. It does more in the area advertised as: none linear gradients of chosen length, more options in computing arbitrary amount of complementary colors, more color mixing options or search for nearby standard colors.

2. It's more convenient. Yes it doesn't convert into all spaces (use Convert::Color for that since Paul did great work there) and it only knows a few standards (use Robert's Graphics::ColorNames if you need more) because I chose only what you need to express yourself. For instance if you want a standard orange - just slightly darker say

my $mo = Graphics::Toolkit::Color->new('orange')
->add( Lightness => -10 );

# L as key would suffice

my @colors = $mo->gradient_to('green', 10, 3);

The second line creates you 10 color objects that give you a transition from your orange to standard green which are not equally distanced, but have a cubic distribution - meaning the first colors will all be near orange getting faster and faster away to green.
And once your machine computed all colors you need just use map extract the wanted values:

my @triplets = map { [$_-> rgb ] } @colors;

That may be RGB triples, HSL triplets, hex values or names. Because if you create

Graphics::Toolkit::Color->new([ 0, 0, 0 ])->name;

of course you get "black". I think you got the idea by now.

Joyful coding!

Leave a comment

About lichtkind

user-pic Kephra, Articles, Books, Perl, Programming