/*
Yingying Yan
Section E
yingyiny@andrew.cmu.edu
Project-05
*/
var oy = 0; // orginal y position
var ox = 0; // original x position
var tw = 50; // the width spacing
var th = 50; // the height spacing
function setup() {
createCanvas(585, 600);
background(234, 185, 83);
}
function draw() {
// for all the odd rolls and columns, we will draw flowers
//by calling the x and y position
for (var y = 0; y < 20; y++) {
for (var x = 0; x < 20; x++) {
if((x % 2 == 1) & (y % 2 == 1)){
var py = oy + y * th;
var px = ox + x * tw;
push();
flower(px, py);
pop();
}
// for all the even rolls and columns, we will draw cactus
// by changing the x and y position
if ((x % 2 == 1) & (y % 2 ==1)){
var ly = oy + y * th;
var lx = ox + x * tw;
push();
cactus(lx, ly);
pop();
}
}
}
noLoop();
}
// function that draws the flower with variables x and y
function flower (x,y) {
translate (x, y);
scale(0.5)
for (var i = 0; i < 7; i += 1) {
fill(147, 87,37, 100);
noStroke();
rectMode(CENTER);
ellipse (0, 0, 20, 100);
rotate(radians(45));
}
}
//function that draws cactus and called by variable x and y
function cactus(x, y) {
translate(x,y);
scale(0.5);
noStroke();
//the vertical stem
fill(90,87,36, 140);
ellipse(100, 100, 10, 100);
// the left rectangle bend
push()
noStroke();
translate(85,110);
rotate(radians(30))
rectMode(CORNER);
rect(0,0, 20, 8);
pop();
//the left ellipse or branch
push();
noStroke();
translate(83, 112);
rotate(radians(-50));
ellipse(0,0, 10, 30);
pop();
//the branch on the right side
push();
translate(100,100)
rotate(radians(-120));
ellipseMode(CORNER);
ellipse(0, 0, 10, 50);
pop();
}
I wanted to draw minions and bananas, but it was too challenging so I ended up drawing flowers and cactus. I like how I accidentally made my flower transparent, that was cool. Then I basically used assignment B’s method to place my flowers and cactus. This project is a little bit stressful than the other ones. As you can tell I turned this in 5 minutes before it is due.