> 16) & 0xFF, ($colour1 >> 8) & 0xFF, $colour1 & 0xFF ];
$colour2 = [ ($colour2 >> 16) & 0xFF, ($colour2 >> 8) & 0xFF, $colour2 & 0xFF ];
return (seria_weighted_number($colour1[0], $colour2[0], $weight) << 16)
| (seria_weighted_number($colour1[1], $colour2[1], $weight) << 8)
| seria_weighted_number($colour1[2], $colour2[2], $weight);
}
function seria_weighted_colour_hex(int $colour1, int $colour2, float $weight): string {
return sprintf('#%06x', seria_weighted_colour($colour1, $colour2, $weight));
}
function seria_easeInQuad(float $n): float {
return $n * $n;
}
function seria_easeOutQuad(float $n): float {
return 1 - (1 - $n) * (1 - $n);
}
function seria_ratio_colour(float $ratio): string {
$ratio *= 2;
if($ratio > 1)
return seria_weighted_colour_hex(0x008000, 0xFFAA00, seria_easeInQuad($ratio - 1));
return seria_weighted_colour_hex(0xFFAA00, 0xFF0000, seria_easeOutQuad($ratio));
}
for($i = 0; $i <= 100; ++$i) {
$if = $i / 100;
printf('%1$01.2f %2$s
', $if, seria_ratio_colour($if));
}