JSGandalf: ConvergingRows

Saturday, December 7, 2019

ConvergingRows

Today I will share with you'll the javascript code for making converging rows.
Code
var wid=100;
var hei=100;
var x=1;
var y=1;
var decrement=0.7;
var ahead=17;
function setup(){
  createCanvas(windowWidth,windowHeight);
  background(0);
  x=0;
  y=1;
}
function draw(){
  if (y<windowHeight){ 
     fill(random(0,255),random(0,255),random(0,255));
     stroke(random(0,255),random(0,255),random(0,255));
     rect(x,y,27,wid,hei);
     x+=wid;
     if (x>windowWidth){
      y+=ahead;
      x=1;
      wid-=decrement;
      hei-=decrement;
        }
    }
    

  }

No comments:

Post a Comment