getHueColour static method
Get the pure color from the Hue angle
.
angle
is in radians
Implementation
static RgbColour getHueColour(num angle)
{
List<RgbColour> slots = [
new RgbColour(255, 0, 0),
new RgbColour(255, 255, 0),
new RgbColour(0, 255, 0),
new RgbColour(0, 255, 255),
new RgbColour(0, 0, 255),
new RgbColour(255, 0, 255)
];
// Each slot is 60 degrees. Find out which slot this angle lies in
// http://en.wikipedia.org/wiki/Hue
int degrees = (angle * 180 / Math.PI).round().toInt();
degrees %= 360;
final slotPosition = degrees / 60;
final slotIndex = slotPosition.toInt();
final slotDelta = slotPosition - slotIndex;
final startColour = slots[slotIndex];
final endColour = slots[(slotIndex + 1) % slots.length];
return startColour + (endColour - startColour) * slotDelta;
}