I'm interesting in algorithms to generate 'n' graduated colors between two given colors, that generate smooth transitions between each of them.
I tried letting static two channels, for example R and G, and incremental change B, but sometimes the difference between two colors are harder than the neighbors have.
I want to check different algorithms and analyze their weakness and strenghts.
I wrote this code and it seems logic, but the transitions between some colors are harder than between other (e.g.between 0 and 1 is harder than between 1 and 2):
<?php $c1 = array(128,175,27); // Color 1 $c2 = array(255,255,140); // Color 2 $nc = 5; // Number of colors to display. $dc = array(($c2[0]-$c1[0])/($nc-1),($c2[1]-$c1[1])/($nc-1),($c2[2]-$c1[2])/($nc-1)); // Step between colors for ($i=0;$i<$nc;$i++){ echo '<div style="width:200px;height:50px;background-color:rgb('.round($c1[0]+$dc[0]*$i).','.round($c1[1]+$dc[1]*$i).','.round($c1[2]+$dc[2]*$i).');">'.$i.'</div>'; // Output } ?>
Are there a better algorithm to do this?
I bring an example: In the code above I used $c1=array(192,5,248);
and $c2 = array(142,175,240);
and $nc = 10;
and obtained this image:

The RGB values of 0,1,8 and 9 are:
- 0 = 192,5,248
- 1 = 186,24,247
- 8 = 148,156,241
- 9 = 142,175,240
If you look there is a diference between neighbor colors of 6,19,1. But the visually transition between 0 and 1 is softer than the transition between 8 and 9. And for HSV is the same thing. It is something with some colors that do its transition harder or softer.