nick34992
4/19/2016 - 3:14 PM

Triangle.Using p5.js library.

Triangle.Using p5.js library.

function setup() {
  createCanvas(720, 400);
}

function draw() {
  background(0, random(128, 255), random(128, 255));
  noStroke(0);
  for (var i = 0; i < 20; i++) {
    // triangle a
    var x1 = random(0, 360);
    var y1 = random(0, 200);
    var x2 = random(360, 720);
    var y2 = random(200, 400);
    var x3 = random(0, 360);
    var y3 = random(0, 200);
    // triangle b
    var x4 = random(360, 720);
    var y4 = random(0, 200);
    var x5 = random(0, 360);
    var y5 = random(200, 400);
    var x6 = random(360, 720);
    var y6 = random(0, 200);
    fill(random(0, 128), random(128, 255), random(0, 128), random(50, 150));
    triangle(x1, y1, x2, y2, x3, y3);
    triangle(x4, y4, x5, y5, x6, y6);
  }
  frameRate(1);
}