# Jason Zhu Project 05

``````/* Jason Zhu
jlzhu@andrew.cmu.edu
Section E
Project 5
*/

// setup variables
function setup() {
createCanvas(600, 400);
background(10, 15, 35);
var tw = 60/sqrt(3); //triangle width (adjusted)
var th = 60; //triange height
var oy = 50; //origin y of circles
var ox = 50; //origin x of circles
var r = 0;

for (var y = 0; y < 6; y++) {
//distinguishes even rows
if (y % 2 == 0){
//even rows: create 6 moon shapes
for (var x = 0; x < 6; x++) {
//position of moons x and y
noStroke()
fill(255);
var py = oy + y * th;
var px = ox + x * 103;
ellipse(px, py, 50, 50);
// create moon shadows and positions x and y
push()
fill(10, 15, 35)
var py = oy + y * th;
var px = ox + x * 93.5;
ellipse(px+50, py, 50, 50);
pop()
}

} else {
//odd rows: create 5 main rectangle lines
for (var x = 0; x < 5; x++) {
var py = oy + y * th;
push()
//set random color and position variables
var r = random(-50,50);
var r2 = random(1, 5);
var red = random(100, 255);
var blue = random(100, 255);
var green = random(100, 255);
//offset origin x by an additional tw
var px = ox + tw + x * 100;
push()
stroke(red, blue, green);
// create 5 offset rectangle lines
rect(px, py, 50, 1);
rect(px +25, py +10, 45, 1)
rect(px -25, py -10, 45, 1)
pop()
// create stars and set color
fill(red, blue, green);
ellipse(px+r, py+r, r2, r2);
}
}
}
noLoop();
}

function draw() {
// draw is not called due to noLoop() in setup()
}
``````

For this project I was inspired to create something that reminded me of stargazing as a child. When prompted to create something I would wear I interpreted that as to create something that I found meaningful to me and my own human experience. I wanted to create a wallpaper that conveyed a sense of time and wonder. Thus, I chose to demonstrate a very implied version of the moon cycle along with some colorful lines and stars that would tie the composition together. In terms of code, I tried to incorporate features from past classes–I added a basic random function to help create a slightly different experience upon each reload. Overall, I am fairly satisfied with the outcome and what I was able to learn from this project.