AS3 Getting colours blended between two other colours
8 years ago
Here is another function that can be added to my ColourUtil class. This one gets a specified number of colour steps between two blended colours.
I thought it would be much harder to achieve than it is, luckily the AS3 Color class has the static method interpolateColor which calculates a single colour at a specified position using a ratio value.
The function below is a simplified version of the function found at AS3 Adventure. This blog post also has a much better explanation of the interpolateColor method, and a great demo of the function.
function getColoursBetween(colour1:uint, colour2:uint, steps:int):Array
var arr = ,
for (i = 1; i < steps; i++)
ratio = i / steps;