Thanks Ashutosh for the math. Play with the code! Make sure to remove the comment tag at /*the beginning and at the end */ which I had to add to prevent blogger from nagging!
/*int NO_OF_CIRCLES = 10;
float[] theta = new float[NO_OF_CIRCLES];
float[] deltaTheta = new float[NO_OF_CIRCLES];
float [][] nextXY = new float[NO_OF_CIRCLES][NO_OF_CIRCLES] ;
//int [][][] colorOFCIRCLE = new int [NO_OF_CIRCLES][NO_OF_CIRCLES][NO_OF_CIRCLES] ;
color[] colors = new color[NO_OF_CIRCLES] ;
void setup()
{
size(400,400);
//setup first case then the rest
theta[0] = 0 ;
for (int i = 1 ; i <>
theta[i] = theta[i-1] + 15 ;
//setup first case then the rest
deltaTheta[0] = 0.01 ;
for (int i = 1 ; i <>
deltaTheta[i] = deltaTheta[i-1] + 0.05;
//offseting individual circle translations. Could be time based or random
deltaTheta[1] = 0.07;
deltaTheta[2] = 0.09;
deltaTheta[3] = 0.05;
deltaTheta[4] = -0.04;
deltaTheta[5] = 0.03;
deltaTheta[6] = -0.06;
deltaTheta[7] = 0.01;
deltaTheta[8] = -0.08;
//assign random colors to all circles
color c1 = color(102, 102, 0);
for (int i = 1 ; i <>
{
colors[i] = color(random(255),random(255),random(255), 125) ;
}
}
void draw()
{
float siz = random(255);
background(0);
nextXY[0][0] = 200; //mouseX;
nextXY[0][1] = 200; //mouseY;
smooth();
noStroke();
fill(0,0,255,126);
//draw first circle
ellipse(nextXY[0][0], nextXY[0][1], 60, 60); // Gray ellipse
theta[0] += deltaTheta[0] ;
//now draw the rest
for (int i = 1; i <>
{
fill((color)colors[i]) ;
nextXY[i][0] = nextXY[i-1][0] + 60 * cos(theta[i-1]) ;
nextXY[i][1] = nextXY[i-1][1] + 60 * sin(theta[i-1]) ;
ellipse(nextXY[i][0], nextXY[i][1], 60, 60);
theta[i] += deltaTheta[i] ;
}
try{
Thread.currentThread().sleep(10);
}catch (InterruptedException ie) {}
}
No comments:
Post a Comment