04 Array

Code in Array

Please try the code blow to see what happens.

function setup() {
  createCanvas(400, 800);
  noLoop();
}

function draw() {

  //rectMode(CENTER);

  let expressions = [
    'line(i * 2, 10, i*2, 90)',
    'line(i , i, i, 50)',
    'line(i , 10, random(100), 90)',
    'rect(0 , 0, 100-i*5, 100-i*5)',
    'rect(0 , i, 100-i*5, 100-i*2)',
    'line(i , 50, i, sin(radians(i*3))*30+ 50)',
    'ellipse(50 , 50, 100-i, 100-i)',
    'ellipse(i , 50, 100-i, 100-i)',
  ];

  for (j = 0; j < expressions.length; j++) {
    text(expressions[j], 110, 10)
    for (let i = 0; i <100; i=i+2) {
      eval(expressions[j]);
    }
    translate(0, 100);
  }
}