xxxxxxxxxx
//This value specifies where in the ellipse orbit
//your object is, from 0 to 2*PI
float val;
float val2;
int count;
boolean run = true;
//The speed your object moves at along the orbit
float speed = random(0.01, 0.4);
float speed2 = random(0.01, 0.4);
void setup(){
size(700, 700);
background(51);
}
void draw(){
//Calculate x and y as values between -1 and 1
float x = sin(val);
float y = cos(val);
float x2 = sin(val2);
float y2 = cos(val2);
//Multiply x and y by the ellipses width and height
x *= 200;
y *= 200;
x2 *= 300;
y2 *= 300;
//Move the centrepoint of the ellipse orbit where you want it
x+= 350;
y+= 350;
x2+= 350;
y2+= 350;
//Update the value and draw
if(run==true){
stroke(255, 25);
line(x, y, x2, y2);
val += speed;
val2 += speed2;
}
if(x>349 && x<351){
if(y>439 && y<451){
count++;
}
}
//Use this to stop the program after a certain amount of full ellipses
if(count==100){
run = false;
}
}