data2image/val2rgb.php
2010-12-21 15:53:40 +00:00

25 lines
491 B
PHP

<?php
$index = $argv[1];
$r = 255;
$g = 0;
$b = 0;
for($i = 0; $i < $index; $i++) {
echo "I:$i\tR:$r G:$g B:$b \n";
if($g === 0 && $b === 255 && $r < 255) $r++;
if($b === 0 && $g === 255 && $r > 0) $r--;
if($b === 0 && $r === 255 && $g < 255) $g++;
if($r === 0 && $b === 255 && $g > 0) $g--;
if($r === 0 && $g === 255 && $b < 255) $b++;
if($g === 0 && $r === 255 && $b > 0) $b--;
}
echo "\n";
print_r(array($i, $r, $g, $b));
?>