Color-Spectrum-Multi-0.02/0000755000175000017500000000000011254424013014675 5ustar davidpdavidpColor-Spectrum-Multi-0.02/lib/0000755000175000017500000000000011254424013015443 5ustar davidpdavidpColor-Spectrum-Multi-0.02/lib/Color/0000755000175000017500000000000011254424013016521 5ustar davidpdavidpColor-Spectrum-Multi-0.02/lib/Color/Spectrum/0000755000175000017500000000000011254424013020323 5ustar davidpdavidpColor-Spectrum-Multi-0.02/lib/Color/Spectrum/Multi.pm0000644000175000017500000000734311254423574021775 0ustar davidpdavidppackage Color::Spectrum::Multi; use warnings; use strict; use base qw(Color::Spectrum); =head1 NAME Color::Spectrum::Multi - simple L wrapper to handle fading between multiple colours. =head1 VERSION Version 0.02 =cut our $VERSION = '0.02'; =head1 SYNOPSIS A simple wrapper around L, to allow generating a range of colours fading between multiple colours (e.g. a red -> yellow -> green fade) easy. Usage is much the same as L, except you can supply as many colours as you wish. # Procedural interface: use Color::Spectrum::Multi qw(generate); my @color = generate(10,'#FF0000','#00FF00', '#0000FF'); # OO interface: use Color::Spectrum::Multi; my $spectrum = Color::Spectrum::Multi->new(); my @color = $spectrum->generate(10,'#FF0000','#00FF00', '#0000FF'); =head1 DESCRIPTION L provides an easy way to fade between two colours in a given number of steps. This module is a simple wrapper around Color::Spectrum, making it easy to fade between an arbitrary number of colours. =head1 METHODS =over =item generate Given the desired number of steps and two or more colours, returns a series of colours. =cut sub generate { my $self = shift if ref($_[0]) eq __PACKAGE__; # If we have two or less colours, just allow Color::Spectrum to do its # thing: if (@_ <= 2) { return Color::Spectrum::generate(@_); } my ($steps, @points) = @_; my @colours; my $steps_used = 0; # take the first colour waypoint off: my $startpoint = shift @points; # How many steps do we get between each waypoint? my $substeps = int($steps / scalar @points); while(my $endpoint = shift @points) { if (@points == 0) { # there's no more points left... make sure we don't fall short # on the number of steps: if (($steps_used + $substeps) != $steps) { $substeps = $steps - $steps_used; } } # Since we start from the last colour of the previous fade, if this # isn't the first fade, we want to generate one extra colour, and drop # the first (otherwise, we'd duplicate colours) my @colour_set = Color::Spectrum::generate( $steps_used ? $substeps+1 : $substeps, $startpoint,$endpoint ); push @colours, $steps_used ? @colour_set[1..$substeps] : @colour_set; # next fade will start from last colour of this fade: $startpoint = $endpoint; $steps_used += $substeps; } return @colours; } =back =head1 AUTHOR David Precious, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Color::Spectrum::Multi You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 COPYRIGHT & LICENSE Copyright 2009 David Precious, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Color::Spectrum::Multi Color-Spectrum-Multi-0.02/Changes0000644000175000017500000000026211254423756016205 0ustar davidpdavidpRevision history for Color-Spectrum-Multi 0.02 2009-09-17 Bah - declaring Color::Spectrum as a dependency would be wise. 0.01 2009-08-25 Initial version Color-Spectrum-Multi-0.02/t/0000755000175000017500000000000011254424013015140 5ustar davidpdavidpColor-Spectrum-Multi-0.02/t/pod-coverage.t0000755000175000017500000000104711253671312017712 0ustar davidpdavidpuse strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); Color-Spectrum-Multi-0.02/t/00-load.t0000755000175000017500000000026011253671312016467 0ustar davidpdavidp#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Color::Spectrum::Multi' ); } diag( "Testing Color::Spectrum::Multi $Color::Spectrum::Multi::VERSION, Perl $], $^X" ); Color-Spectrum-Multi-0.02/t/pod.t0000755000175000017500000000035011253671312016115 0ustar davidpdavidp#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Color-Spectrum-Multi-0.02/t/01-basic-operation.t0000755000175000017500000000262011253671312020632 0ustar davidpdavidp#!perl -T use strict; use Color::Spectrum::Multi; use Test::More; # Tests to perform. Each consists of a set of parameters to pass, and a list of # colours we expect to receive. my @tests = ( [ [ 5, '#FF0000', '#00FF00' ], [ split /\s+/, '#FF0000 #E85500 #AAAA00 #55E800 #00FF00' ], ], [ [7, '#FF0000', '#00FF00', '#0000FF'], [ split /\s+/, '#FF0000 #AAAA00 #00FF00 #00E855 #00AAAA #0055E8 #0000FF' ], ], ); # Declare the number of tests we expect to run. For each set of test data, we # will run a set of 4 tests, twice. plan tests => ( 2 * 4 ) * @tests; # For each test, call the module both ways, and check the result looks as we # expect (overkill, but doesn't hurt): for my $test (@tests) { # Do this test procedurally: my @result = Color::Spectrum::Multi::generate(@{ $test->[0] }); _check_result(\@result, $test->[1]); # And now OO-style: my $spectrum = Color::Spectrum::Multi->new; @result = $spectrum->generate(@{ $test->[0] }); _check_result(\@result, $test->[1]); } # Ensure the result of a test looks good. sub _check_result { my ($result, $test_expects) = @_; ok(ref $result eq 'ARRAY', "Got an array from this test"); ok(@$result > 2, "Array contains at least two colours"); is(@$result, @$test_expects, "Correct number of colours"); is_deeply($result, $test_expects, "Got the colours we expected"); } Color-Spectrum-Multi-0.02/MANIFEST0000644000175000017500000000031311254424013016023 0ustar davidpdavidpChanges MANIFEST Makefile.PL README lib/Color/Spectrum/Multi.pm t/00-load.t t/01-basic-operation.t t/pod-coverage.t t/pod.t META.yml Module meta-data (added by MakeMaker) Color-Spectrum-Multi-0.02/Makefile.PL0000644000175000017500000000121611254423553016657 0ustar davidpdavidpuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Color::Spectrum::Multi', AUTHOR => 'David Precious ', VERSION_FROM => 'lib/Color/Spectrum/Multi.pm', ABSTRACT_FROM => 'lib/Color/Spectrum/Multi.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Color::Spectrum' => 0, 'Test::More' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Color-Spectrum-Multi-*' }, ); Color-Spectrum-Multi-0.02/README0000644000175000017500000000240511253671312015563 0ustar davidpdavidpColor-Spectrum-Multi A very simple wrapper around Color::Spectrum, to make fading between more than two colours simple and pleasant. See Color::Spectrum's documentation - the only difference using Color::Spectrum::Multi is that you can supply as many colours as you wish. For instance, you could fade from red, through yellow, to green: my $spectrum = Color::Spectrum::Multi->new; my @colors = $spectrum->generate(15, '#FF0000', '#FFEE00', '#00FF00'); INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Color::Spectrum::Multi You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Color-Spectrum-Multi AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Color-Spectrum-Multi CPAN Ratings http://cpanratings.perl.org/d/Color-Spectrum-Multi Search CPAN http://search.cpan.org/dist/Color-Spectrum-Multi/ COPYRIGHT AND LICENCE Copyright (C) 2009 David Precious This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Color-Spectrum-Multi-0.02/META.yml0000644000175000017500000000100311254424013016140 0ustar davidpdavidp--- #YAML:1.0 name: Color-Spectrum-Multi version: 0.02 abstract: simple L wrapper to handle fading license: perl author: - David Precious generated_by: ExtUtils::MakeMaker version 6.42 distribution_type: module requires: Color::Spectrum: 0 Test::More: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3