need help with translate
in
Programming Questions
•
1 year ago
here is the code that I have. I am trying to get the pulsating circle to be evenly placed all over the screen rather than just pulsating from the origin. I think my problem is with translate but it could also be my understanding of and use of the sin function. Any help or suggestions are great.
float r= 300;
float angle=0.0;
float speed =.05;
void setup(){
size(400,400);
smooth();
}
void draw(){
background(0);
angle += speed ;
float sinval= sin(angle);
float yoff= sinval * r;
// translate(width/2 , height/2);
scale(yoff/900 +.5);
fill(random(200), 50, random(90));
ellipse(0,0, 80,80);
fill(random(20), 150, random(200));
scale(yoff/900 +.5);
//translate(160, 0);
ellipse(160,0, 80,80);
fill(random(20), 150, random(200));
scale(yoff/900 +.5);
// translate(60, 0);
ellipse(80,0, 80,80);
}
float r= 300;
float angle=0.0;
float speed =.05;
void setup(){
size(400,400);
smooth();
}
void draw(){
background(0);
angle += speed ;
float sinval= sin(angle);
float yoff= sinval * r;
// translate(width/2 , height/2);
scale(yoff/900 +.5);
fill(random(200), 50, random(90));
ellipse(0,0, 80,80);
fill(random(20), 150, random(200));
scale(yoff/900 +.5);
//translate(160, 0);
ellipse(160,0, 80,80);
fill(random(20), 150, random(200));
scale(yoff/900 +.5);
// translate(60, 0);
ellipse(80,0, 80,80);
}
1