Color Spectrum (incomplete)


/ Published in: ActionScript 3
Save to your folder(s)

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/HSL_color_space


Copy this code and paste it in your HTML
  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;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.