Posted By

forchid on 09/13/09


Tagged

hex operator color bitwise as3 spectrum


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

StrawMan
mali


Color Spectrum (incomplete)


 / Published in: ActionScript 3
 

URL: http://www.boostworthy.com/blog/?p=200

This is an incomplete color spectrum because cos waves will not reach all the colors. For a proper graph refer to this wiki page http://en.wikipedia.org/wiki/HSLcolorspace

  1. // BITWISE OPERATORS
  2.  
  3. // HEX
  4. var color24:Number = 0xFF >> 16 | 0x55 >> 8 | 0xF3;
  5.  
  6.  
  7. // Decimal
  8. var color24:Number = 255 >> 16 | 85 >> 8 | 243;
  9.  
  10.  
  11. // Extracting
  12. red = color24 >> 16;
  13. green = color24 >> 8 & 0xFF;
  14. blue = color24 & 0xFF;
  15.  
  16. // DRAWING SPECTRUM
  17. nR = Math.cos(nRadians) * 127 + 128 << 16;
  18. nG = Math.cos(nRadians + 2 * Math.PI / 3) * 127 + 128 << 8;
  19. nB = Math.cos(nRadians + 4 * Math.PI / 3) * 127 + 128;
  20.  
  21. nColor = nR | nG | nB;

Report this snippet  

You need to login to post a comment.