
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 0.57 KB | hits: 9 | expires: Never
Core Plot: Random Colors for Scatter Plot(s)
float red = 0;
float blue = 0;
float green = 0;
while(need more colors){
float colorToInc = (arc4Random()%100)/100;
float incValue = (arc4Random()%100)/500;//value between 0 and .2
if(colorToInc < .3){
red += incValue;
if(red > 1)
red -= 1;
}else if(colorToInc < .7){
green += incValue;
if(green > 1)
green -= 1;
}else{
blue += incValue;
if(blue > 1)
blue -= 1;
}
newcolor = [color with red:red blue:blue green:green];
}