xxxxxxxxxx
let big = [],
med = [],
small = [];
let cols = 25;
let rows = 25;
var cellW, cellH;
function preload() {
med.push(loadImage('1.png'));
small.push(loadImage('2.png'));
small.push(loadImage('3.png'));
big.push(loadImage('4.png'));
small.push(loadImage('5.png'));
med.push(loadImage('6.png'));
big.push(loadImage('7.png'));
small.push(loadImage('8.png'));
small.push(loadImage('9.png'));
med.push(loadImage('10.png'));
med.push(loadImage('11.png'));
big.push(loadImage('12.png'));
small.push(loadImage('13.png'));
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(65, 105, 225);
cellW = width / cols;
cellH = height / rows;
//background(240);
angleMode(DEGREES)
frameRate(10);
}
function mousePressed() {
save("pattern.svg");
}
function draw() {
var img;
var x, y;
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
var r = random(9.6);
if (r < 8) img = random(small);
else if (r >= 8 && r < 9.5) img = random(med);
else img = random(big);
x = i * cellW + cellW / 2;
y = j * cellH + cellH / 2;
push();
translate(x, y);
rotate(random(360));
imageMode(CENTER);
var h = (cellH>cellW) ? cellH:cellW
image(img, 0, 0, h * 3.5, h * 3.5);
pop();
}
}
noLoop();
}