/ p5 / re-code 16

function setup() {
 createCanvas(780,780); 
}

// Draws a single cross.
function drawCross(left, top, dim, thickness) {
 var offset_1 = dim/2 - thickness/2;
 var offset_2 = offset_1 + thickness;
 var offset_3 = dim;
 beginShape();
 vertex(left + offset_1, top);
 vertex(left + offset_2, top);
 vertex(left + offset_2, top + offset_1);
 vertex(left + offset_3, top + offset_1);
 vertex(left + offset_3, top + offset_2);
 vertex(left + offset_2, top + offset_2);
 vertex(left + offset_2, top + offset_3);
 vertex(left + offset_1, top + offset_3);
 vertex(left + offset_1, top + offset_2);
 vertex(left, top + offset_2);
 vertex(left, top + offset_1);
 vertex(left + offset_1, top + offset_1);
 vertex(left + offset_1, top);
 endShape(CLOSE);
}

// Draw a stack of crosses.
function drawCrossWithDecay(left, top, base_dim, num_decay, dpos, ddim, dthickness) {
 var thickness = base_dim/3;
 var dim = base_dim;
 var curleft = left;
 var curtop = top;
 for (var i = 0; i < num_decay; i++) {
 drawCross(curleft, curtop, dim, int(thickness));
 curleft += dpos.x + ddim/2;
 curtop += dpos.y + ddim/2;
 dim -= ddim;
 thickness -= dthickness;
 }
}

function drawCrossMatrix(dim, left, top, rows, cols) {
 var thickness = dim/3;
 var dp1 = createVector(0,-1);
 var dp2 = createVector(1,0);
 var dp;
 for (var i = 0; i < rows; i++) {
 var rleft = left + i * thickness;
 var rtop = top + i * 2 * thickness;
 for (var j = 0; j < cols; j++) {
 dp = i%2==0?dp1:dp2;
 dp.mult(-1);
 drawCrossWithDecay(rleft + thickness * 2 *j, rtop - thickness * j, dim, 5, dp, 4, 4.5);
 } 
 }
}

function draw() {
 background(255);
 
 drawCrossMatrix(80, 50, 150, 6, 6);
}