xxxxxxxxxx
38
// This sketch demonstrates the working of:
// Gen.spread();
// require libraries from TotalSerialism
const Gen = TotalSerialism.Generative;
const Mod = TotalSerialism.Transform;
let col = 5;
let row = 5;
let amt = col * row;
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
noStroke();
fill(255);
}
function draw() {
background(0);
// created x and y coordinates for cubes
let posX = Gen.spread(col, width);
let posY = Gen.spread(row, height);
// spread size from 4 pixels to width/columns
let size = Gen.spread(amt, 4, height/col);
for (let i in size){
let x = i % col;
let y = floor(i / col);
let xOffset = (width/col/2);
let yOffset = (height/row/2);
rect(posX[x]+xOffset, posY[y]+yOffset, size[i], size[i]);
}
}