push/pop background? or reset one ellipse background and other not
in
Programming Questions
•
5 months ago
Hi!
I got one green and one red ellipse. I want the red one to make a straight line while the green one to just reset everytime in draw. I tried to accomplish this through push and popStyle() but i doesnt seem to work on background()
Maybe if you think in layers, I want one layer to reset the background and one layer to not reset the background in draw.
any hints?
thanks!
I got one green and one red ellipse. I want the red one to make a straight line while the green one to just reset everytime in draw. I tried to accomplish this through push and popStyle() but i doesnt seem to work on background()
Maybe if you think in layers, I want one layer to reset the background and one layer to not reset the background in draw.
any hints?
thanks!
- float slow_circle_x = 0; // slow green
- float fast_circle_x = 0; // fast red
- void setup() {
- size(400, 400);
- noStroke();
- }
- void draw() {
- background(#1BB1F5);
- fill(#C1FF3E); // green ellipse
- ellipse(slow_circle_x, 50, 50, 50);
- slow_circle_x = slow_circle_x + 1;
- fill(#FF4800); // red ellipse
- ellipse(fast_circle_x, 50, 50, 50);
- fast_circle_x = fast_circle_x + 5;
- if (slow_circle_x > 400) { // start over green
- slow_circle_x = 0;
- }
- if (fast_circle_x > 400) { // start over red
- fast_circle_x = 0;
- }
- }
1