//Grace Wanying Hou
//15-104 Section D
//ghou@andrew.cmu.edu
//Assignment 05 A
//globals
//rectangles
var lx = 60;
var ly = 40;
var rx;
var ry;
//diagonals
var dx = 0;
var dy = 0;
var dyn = 0;
function setup(){
createCanvas(600,600);
background (255);
angleMode(DEGREES);
}
function draw(){
for (var y = 0; y < height/ly; y++) {
for (var x = 0; x < width/lx; x++) {
//local variable (needs to change w each square);
//circles
var sizes = [0,0,0,lx,lx*2,lx*3];
var csize = random(sizes);
//transparency
var tran1 = random(20,100);
//lineweight
var linew = random(0.1,1);
var cirw = random();
//colour
var colr = randomGaussian(200,20);
var colg = randomGaussian(200,20);
var colb = randomGaussian(200,20);
//rectangles
noStroke();
rx = x * lx;
ry = y * ly;
fill(colr,colg,250,tran1);
rect(rx,ry,lx,ly);
//circles
strokeWeight(linew);
stroke(255);
fill(250,colg,colb,tran1);
ellipse(rx,ry,csize);
}
}
for (var y = -2; y < height/ly; y++) {
for (var x = -2; x < width/lx; x++) {
var linew = random(0.5,1);
//rect strokes
rx = x * lx;
ry = y * ly;
stroke(255);
strokeWeight(2);
noFill();
rect(rx,ry,lx,ly);
//diagonals
dx = (x + 1) * lx;
dy = (y + 1) * ly;
strokeWeight(linew);
//lines crossing rectangle
line(rx,ry,dx,dy);
line(dx,ry,rx,dy);
//lines crossing each 3 rectangles
dyn = (y + 3) * ly;
line(rx,ry,dx,dyn);
line(dx,ry,rx,dyn);
}
}
noLoop()
}
I wanted to create a wallpaper more suited to be a wallpaper for a phone or an iPad. Based on that, I wanted to make something more geometric. I used a Gaussian randomizer to more easily make it look more naturally generated.