For this project I wanted to create a geometric pattern and was inspired by the designs on the antique wallpaper website. I experimented with various shapes, variables and colors before arriving at a final result. I particularly focused on creating quadrangles through diagonal lines.
//Ankitha Vasudev
//ankithav@andrew.cmu.edu
//Section B
//Project 05
//global variables
var l = 25;
var diameter = 10;
var spacing = 50;
function setup() {
createCanvas(400, 400);
noLoop();
}
function draw() {
background(210, 140, 190);
//command to draw wallpaper
drawWallPaper();
}
function drawWallPaper() {
//thin yellow lines
stroke(255, 215, 50);
strokeWeight(8);
for (var x = 0; x<=width; x += spacing) {
for (var y = 0; y <= height; y+=spacing) {
line(x-l, y+l, x+l, y-l);
line(x+l, y+l, x-l, y-l);
line(x-l, y+l, x+l, y-l);
line(x+l, y+l, x-l, y-l);
}
}
//thick blue diagonal lines
stroke(130, 190, 230);
strokeWeight(4);
for (var x = 0; x<=width; x += spacing) {
for (var y = 0; y <= height; y+=spacing) {
line(x-l, y+l, x+l, y-l);
line(x+l, y+l, x-l, y-l);
line(x-l, y+l, x+l, y-l);
line(x+l, y+l, x-l, y-l);
}
}
//inner squares
strokeWeight(2);
stroke(255, 215, 50);
fill(255, 70, 160);
for (var x = 0; x<=width; x += spacing/2) {
for (var y = 0; y <= height; y+=spacing) {
rectMode(CENTER);
rect(x, y, l/4, l/4);
}
}
//circles
strokeWeight(4);
stroke(130, 190, 230);
fill(220);
for (var x = 0; x<=width; x += spacing) {
for (var y = 0; y <= height; y+=spacing) {
ellipse(x, y, diameter);
}
}
}