Chart:...locator(3pm)

๐Ÿ“ฆ
version 2.90 ยท 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

Chart::Clicker::Drawing::ColorAllocator โ€” it's a color picker, bestie. That's it, that's the whole vibe. (This is one of the user-contributed Perl docs, so you already know it's gonna be a little quirky. ๐ŸŽ€)


โœจ VERSION โœจ

version 2.90 โ€” yes she's been around a while and yes she still ate. ๐Ÿ’…


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

Okay so here's the whole situation, no cap:

use Graphics::Color::RGB;
use Chart::Clicker::Drawing::ColorAllocator;

my $ca = Chart::Clicker::Drawing::ColorAllocator->new({
    colors => [
        Graphics::Color::RGB->new(
            red => 1.0, green => 0, blue => 0, alpha => 1.0
        ),
        #...
    ]
});

my $red = $ca->get(0);

#or let Chart::Clicker autmatically pick complementing colors for you
my $ca2 = Chart::Clicker::Drawing::ColorAllocator->new({
    seed_hue => 0, #red
});

Like โ€” you can hand her your own little palette of colors, OR you can just say "girl, you pick" and let Chart::Clicker do the choosing for you. Main character energy either way. ๐Ÿฆ‹


๐ŸŒธ DESCRIPTION ๐ŸŒธ

She allocates colors for use in the chart. The position in the color allocator corresponds to the series that will be colored โ€” so like, slot 0 colors series 0, slot 1 colors series 1, and so on. It's giving matchmaker but for your data series. ๐Ÿ”ฅ


๐Ÿ’ซ AUTOMATIC COLOR ALLOCATION ๐Ÿ’ซ

Not me being obsessed with this feature. This module has the capacity to automatically allocate 96 individual colors using Color::Scheme. Periodt. ๐Ÿ’…

Here's how she does it: she picks 4 hues equally spaced in the color wheel from the "seed_hue" โ€” so if you seed with 0 (red), that gets complimented by 270 (blue), 180 (green) and 90 (yellow). Cute, right? Then after those colors are allocated, she moves on to picking from the colors between those, i.e. 45, 135, 215, 305, etc. Once all values of "hues" have been utilized, she repeats them using a different shade. ๐ŸŒˆ

The whole effect is that she's generating evenly spaced complementing colors, so your colors stay well ditinguishable from one another and have appropriate contrast. She will never let your chart look a mess. ๐Ÿ™ˆ

๐Ÿ“ position

Gets the current position. Simple as that. (Where are we in the color lineup, bestie?)


๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

๐ŸŽจ colors

An arrayref of colors that will be used for series that Clicker draws. This is your custom palette โ€” hand her the crayons and she'll use them.

๐Ÿงต color_scheme

A lazy-building Color::Scheme object used to generate the color scheme of the chart. Lazy as in she only builds it when she actually needs it โ€” efficient queen. ๐Ÿ’…

๐ŸŒก๏ธ seed_hue

The interger value of the first hue used when computing the tetrade color scheme. Setting this will affect the hue of the first color allocated. Subsequent colors will be allocated based on their distance from this color, to maintain sifficient contrast between colors. If you don't specify it, the seed_hue will default to 270, blue. ๐Ÿ’™ So like, if you don't pick, she's picking blue for you. Respect.

๐Ÿฆ‹ hues

An array reference of evenly spaced seed hues for color allocation. By default it will use the seed hue plus 0, 45, 75, 15, 60 and 30 โ€” which is enough to cover all web-safe colors when using a tetrade color scheme. Yeah she did the math so you don't have to. ๐Ÿงฎโœจ

๐Ÿ“ shade_order

An array reference of the order in which the different shades of each color will be used for every color scheme generated. It defaults to 1, 3, 0, 2 for optimum color spacing. Iconic ordering tbh.


๐Ÿซถ METHODS ๐Ÿซถ

โž• add_to_colors

Add a color to this allocator. A little treat for her. ๐ŸŽ

๐Ÿงน clear_colors

Clear this allocator's colors. Boom, gone, empty, fresh start. โœจ

๐Ÿ”ข color_count

Get the number of colors in this allocator. How many do we have, bestie?

๐ŸŽฏ get_color ($index)

Gets the color at the specified index. Returns undef if that position has no color. So yeah, no color there means you get undef, not a surprise, not a crash โ€” just undef. ๐Ÿ™ˆ

โžก๏ธ next

Returns the next color. Each call to next increments the position, so subsequent calls will return different colors. She never gives you the same one twice in a row. Obsessed. ๐Ÿ’–

๐Ÿงช allocate_color

Determines what the next color should be. The brains of the operation, fr fr.

๐Ÿ”„ reset

Resets this allocator back to the beginning. Rewind time, back to square one, slay. โช


โœ๏ธ AUTHOR โœ๏ธ

Cory G Watson <gphat@cpan.org> โ€” thank you for your service, king. ๐Ÿ‘‘


This software is copyright (c) 2016 by Cory G Watson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free software, free as in freedom, we love to see it. ๐ŸŒˆ


Go forth and color your charts, bestie. Your series deserve contrast and your eyes deserve nice things. ๐ŸŽ€๐Ÿ’–

perl v5.36.0 โ€” 2022-10-14 โ€” that's the version and the date this page was generated, mwah, bye! ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from