Color-Spectrum-Multi
view release on metacpan or search on metacpan
lib/Color/Spectrum/Multi.pm view on Meta::CPAN
}
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
( run in 0.591 second using v1.01-cache-2.11-cpan-df04353d9ac )