SNIPPLR.com Find – Color Spectrum


September 18th, 2009

Found this really cool little snip of actionscript, that creates a color spectrum!

BITWISE OPERATORS

// HEX
var color24:Number = 0xFF >> 16 | 0x55 >> 8 | 0xF3;

// Decimal
var color24:Number = 255 >> 16 | 85 >> 8 | 243;

// Extracting
red = color24 >> 16;
green = color24 >> 8 & 0xFF;
blue = color24 & 0xFF;

// DRAWING SPECTRUM
nR = Math.cos(nRadians)                   * 127 + 128 << 16;
nG = Math.cos(nRadians + 2 * Math.PI / 3) * 127 + 128 << 8;
nB = Math.cos(nRadians + 4 * Math.PI / 3) * 127 + 128;

nColor  = nR | nG | nB;
ColorSpectrum

ColorSpectrum


Related Posts

Leave a Reply