Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Core Plot: Random Colors for Scatter Plot(s)
  2. float red = 0;
  3. float blue = 0;
  4. float green = 0;
  5. while(need more colors){
  6.     float colorToInc = (arc4Random()%100)/100;
  7.     float incValue = (arc4Random()%100)/500;//value between 0 and .2
  8.     if(colorToInc < .3){
  9.         red += incValue;
  10.         if(red > 1)
  11.             red -= 1;
  12.     }else if(colorToInc < .7){
  13.         green += incValue;
  14.         if(green > 1)
  15.             green -= 1;
  16.     }else{
  17.         blue += incValue;
  18.         if(blue > 1)
  19.             blue -= 1;
  20.     }
  21.     newcolor = [color with red:red blue:blue green:green];
  22. }