CheerLights::API is a Perl module that provides an interface to the CheerLights API. It allows you to retrieve the current color, color history, and other useful functions related to CheerLights, a project that synchronizes connected lights globally based on social media interactions.
🌍 🎨 💡
- Get the current CheerLights color with its name and hex code.
- Retrieve the history of recent colors.
- Convert color names to hex codes.
- Convert hex codes to RGB tuples.
- Check if a color name is valid in the CheerLights context.
.-=-. .-=-. .-=-.
_( )__ _( )__ _( )__
(_________)(_________)(_________)
| | | | | |
| | | | | |
-----' '------' '------' '-----
- Copy the
CheerLights/API.pm
file to your desired module directory (lib/
). - Use the module in your Perl script by including
use CheerLights::API
.
use CheerLights::API qw(get_current_color get_current_hex get_color_history color_name_to_hex hex_to_rgb is_valid_color);
Get the Current Color
my $current_color = get_current_color();
print "Current color: $current_color->{color}, Hex: $current_color->{hex}\n";
Get the Current Hex Code
my $hex = get_current_hex();
print "Current hex color: $hex\n";
Get the Color History
my $history = get_color_history(5);
foreach my $entry (@$history) {
print "Color: $entry->{color}, Hex: $entry->{hex}, Timestamp: $entry->{timestamp}\n";
}
Convert a Color Name to Hex
my $hex_code = color_name_to_hex('red');
print "Hex code for red: $hex_code\n";
Convert a Hex Code to RGB
my @rgb = hex_to_rgb('#FF0000');
print "RGB values for #FF0000: @rgb\n";
Check if a Color Name is Valid
my $is_valid = is_valid_color('blue');
print "Is 'blue' a valid color? ", $is_valid ? 'Yes' : 'No', "\n";
Returns the current CheerLights color as a hash reference with color
and hex
keys.
Returns the current hex code of the CheerLights color.
Returns the current color name of the CheerLights.
Takes an integer $count
(default is 10) and returns an array reference of the most recent color data, each containing color
, hex
, and timestamp
.
Converts a given color name to its corresponding hex code.
Converts a hex code to an RGB tuple.
Checks if a color name is valid according to CheerLights' list.
- Perl 5.10+
- Modules:
LWP::UserAgent
JSON
Install required modules using CPAN:
cpan LWP::UserAgent JSON