xxxxxxxxxx
var bgColor; //bg color
var stColor; // stroke color
var x;
var y;
var sz; //size of each square
var gap; //Distance between each square
var stw; //stroke weight of each square
var dice;
function setup() {
createCanvas(600, 600);
background(100);
bgColor = '#ffffff'
sz = 100;
stColor = '#333fff'
x = 0;
y = 0;
gap = 10;
stw = 1;
noLoop();
angleMode(DEGREES);
}
function draw() {
background(bgColor);
//set rect mode
rectMode(CENTER);
for (var i = 0; i < 10; i = i + 1) {
for (var j = 0; j < 10; j = j + 1) {
dice = random(0, 1);
var curRot = 0;
if (dice > 0.8) {
curRot = 90;
}
if (dice > 0.3 && dice < 0.5) {
curRot = 180;
}
if (dice > 0.5 && dice < 0.8) {
curRot = 270;
}
push();
translate(sz * i, sz * j);
push();
translate(50, 50);
rotate(curRot);
translate(-50, -50);
drawGrid();
pop();
pop();
}
}
}
function drawGrid() {
noStroke();
x = 25;
y = 50;
fill('#333fff')
rect(x, y, 50, sz)
x = 75;
y = 50;
fill('#33ff99')
rect(x, y, 50, sz)
fill('#cc0066')
triangle(48, 100, 0, 50, 0, 100)
fill('#FAC123')
triangle(100, 50, 100, 100, 50, 100)
}