in reply to Gradient Images
A simple way is just to interpolate (separately) the red, green, and blue components of the first and last colors, by determining how much they should change at each step of the gradient.
YuckFoo
#!/usr/bin/perl use strict; # Desired number of steps my $steps = 16; # RGB components of random beginning and ending colors my @beg = (int(rand(256)), int(rand(256)), int(rand(256))); my @end = (int(rand(256)), int(rand(256)), int(rand(256))); # RGB rate of change from beginning to ending color my @delta = ( ($end[0] - $beg[0]) / ($steps-1), ($end[1] - $beg[1]) / ($steps-1), ($end[2] - $beg[2]) / ($steps-1), ); # Calculate colors using beginning color and rate of change for my $i (0..$steps-1) { printf("%3d %3d %3d %3d\n", $i, $beg[0] + $i * $delta[0], $beg[1] + $i * $delta[1], $beg[2] + $i * $delta[2]); }
|
|---|