Using frameCount and modulus to make an animation seem slower
in
Programming Questions
•
3 months ago
I'm trying to write this so that every 5 frames, an ellipse is drawn, and on the other frames, a rectangle is drawn (to make the ellipse fade out slowly). Help? This returns the error "unexpected token: frameCount"
- void setup (){
- size (1280,720);
- ellipseMode (CENTER);
- rectMode(CENTER);
- frameRate (30);
- background (0);
- strokeWeight (5);
- }
- color[] colorList = {color(255,78,80), color(252,145,58), color(249,212,35), color(237,229,116), color(225,245,196),}; //Creates a list of colors. Add more in a comma-separated list...
- void draw () {
- int w = width;
- int h = height;
- float d = random(150, 300);
- float x = random(0, width);
- float y = random(0, height);
- color randomColor = colorList[ (int) random(colorList.length) ];
- for (frameCount > 0) {
- if (frameCount % 5 = 0 ) {
- fill(random(77+-25), random(209+-25), random(230+-25), 100);
- stroke(0,0,0,10);
- ellipse (x, y, d, d);
- } else {
- noStroke ();
- fill(0,10);
- rect(w/2,h/2,w,h);
- }
- //saveFrame("frame##.png"); // saves frame to sketch folder when mouse pressed
- }
1