xxxxxxxxxx
var colors = '0c0f0a-ff206e-fbff12-41ead4-ffffff'.split('-').map((x) => '#' + x)
var columns;
var rows;
var w;
function setup() {
createCanvas(windowWidth, windowHeight);
w = width/24
columns = floor(width/w);
rows = floor(height/w);
background('white');
var color = random(colors)
var tileCounter = 0
for ( var i = 0; i < columns;i++) {
for ( var j = 0; j < rows;j++) {
if (i<j) {
var color = random(colors)
var tileType = int(random(6))
}
var tileCenter = createVector(i*w + w/2, j*w + w/2);
drawTile(tileCenter, tileType, i, j, color)
tileCounter++
}
}
}
function drawTile(tileCenter, tileType, col_idx, row_idx, color) {
push()
translate(tileCenter.x, tileCenter.y)
switch(tileType) {
case 0:
beginShape()
fill(color)
vertex(-w/2,-w/2)
bezierVertex(w/2,-w/2, w/2, w/2, -w/2,-w/2)
rotate(int(random(4)) * PI/2)
endShape(CLOSE)
break;
case 1:
beginShape()
vertex(-w/2,-w/2)
vertex(-w/2, w/2)
vertex( w/2, w/2)
rotate(int(random(4)) * PI/2)
endShape(CLOSE)
break;
case 2:
beginShape()
fill(color)
vertex(-w/2,-w/2)
bezierVertex(-w/2,-w/2, w/2,-w/2, w/2, w/2)
rotate(int(random(4)) * PI/2)
endShape(CLOSE)
break;
case 3:
beginShape()
fill(color)
strokeWeight(1)
circle(0, 0, w);
endShape(CLOSE)
break;
case 4:
fill(color)
for (var i=0;i<4;i++) {
beginShape()
vertex(-w/2,-w/2)
bezierVertex(-w/2, w/2, w/2, -w/2, -w/2, -w/2)
rotate(int(random(4)) * PI/2)
endShape(CLOSE)
}
break;
case 5:
for (var i=0;i<4;i++) {
beginShape()
fill(color)
vertex(-w/2,-w/2)
vertex(-w/2, w/2)
vertex( w/2, -w/2)
vertex( w/2, w/2)
endShape(CLOSE)
}
break;
}
pop()
}
function draw() {
}