Project 05 – Wallpaper

Stereoscopic style wallpaper with randomly generated shapes throughout composition.

sketch
//Aarnav Patel
//Section D
//aarnavp@andrew.cmu.edu
//Project-05

var side = 100;
var radius = 0.8 * side
function setup() {
    createCanvas(600, 600);
    background(0);
}

function draw() {
	noStroke();

	let arr1 = [1, 2, 3];
	count = 0;
	for (var y = 0; y < height; y += side) {
		count = count + 1; 
		for (var x = 0; x < width; x += side) {
			if (count == floor(random(0, 5))) {
				drawTile(x, y);
				drawRandomShape(x, y);
				count = 0;
			} else {
				drawTile(x, y);
			}
		}
	}
	noLoop();
}

function drawTile(x, y) {
	fill(0, 0, 255, 150);
	ellipse(x + side / 2, y + side / 2, radius);
	fill(255, 0, 0, 100);
	ellipse(x + radius / 2, (y + side / 2 ), radius);

	fill(0, 0, 255, 100);
	triangle(x - 5, y - 5, (x + side) - 5, y - 5, x - 5, (y + side) - 5);
	fill(255, 0, 0, 150);
	triangle(x, y, x + side, y, x, y + side);

}

function drawRandomShape(x, y) {
	var r = floor(random(0, 3));
	fill(255);

	if (r == 0) {
		rectMode(CENTER);
		rect(x + (side / 2), y + (side / 2), side * 0.1, side * 0.5);
		rect(x + (side / 2), y + (side / 2), side * 0.5, side * 0.1);
	} else if (r == 1) {
		rectMode(CENTER);
		rect(x + (side / 2), y + (side / 2), side * 0.1, side * 0.5);
	} else {
		rectMode(CENTER);
		rect(x + (side / 2), y + (side / 2), side * 0.5, side * 0.1);
	}
}

Leave a Reply