Week 4 - Homework 1: Visualize pattern in nature/objects
This week we had to find and visualize a pattern in nature or objects. Last week, I went on a sighseeing-trip around Seoul and saw Cosmos flowers planted around one of the places we visited. The image of the flowers stuck out to me and served as my ispiration for this assignment.
This is the image I used for reference (not photographed by me):
And the result turned out like this:
size (600, 500);
noLoop();
background(65, 148, 10);
}
void draw (){
//Loop pink flower
for(int i=0; i < 7; i++){
pushMatrix();
//radomizing flower placement
translate(random(-200, 200), random(-200, 200));
//petal color
fill(255, 143, 214);
stroke(212, 87, 166);
//Petal furthest to the right
ellipse (350, 250, 100, 50);
//Petal between right and down
pushMatrix();
rotate(radians(45));
ellipse (435, -35, 100, 50);
popMatrix();
//Petal furthest to the left
ellipse(250, 250, 100, 50);
//Petal between left and up
pushMatrix();
rotate(radians(45));
ellipse(337, -35, 100, 50);
popMatrix();
//Petal furthest on top
ellipse(300, 200, 50, 100);
//Petal between top and right
pushMatrix();
rotate(radians(315));
ellipse (85, 390, 100, 50);
popMatrix();
//Petal furthest down
ellipse(300, 300, 50, 100);
//Petal between down and left
pushMatrix();
rotate(radians(315));
ellipse (-10, 390, 100, 50);
popMatrix();
// flower center
fill(255, 196, 0);
noStroke();
circle(300, 250, 26);
popMatrix();
}
//Loop white flower
for(int i=0; i < 7; i++){
pushMatrix();
//radomizing flower placement
translate(random(-200, 200), random(-200, 200));
//petal color
fill(255);
stroke(125);
//Petal furthest to the right
ellipse (350, 250, 100, 50);
//Petal between right and down
pushMatrix();
rotate(radians(45));
ellipse (435, -35, 100, 50);
popMatrix();
//Petal furthest to the left
ellipse(250, 250, 100, 50);
//Petal between left and up
pushMatrix();
rotate(radians(45));
ellipse(337, -35, 100, 50);
popMatrix();
//Petal furthest on top
ellipse(300, 200, 50, 100);
//Petal between top and right
pushMatrix();
rotate(radians(315));
ellipse (85, 390, 100, 50);
popMatrix();
//Petal furthest down
ellipse(300, 300, 50, 100);
//Petal between down and left
pushMatrix();
rotate(radians(315));
ellipse (-10, 390, 100, 50);
popMatrix();
// flower center
fill(255, 196, 0);
noStroke();
circle(300, 250, 26);
popMatrix();
}
}
I started by making one single flower in the center of the window and worked with getting the angle and placement of the petals as I wanted them. After that, I added the loop, and used translate to get the placement of the flower as a whole to change randomly. After that I colored the flowers and decided that I wanted flowers in two different colors; so I used copy-pasted the loop and changed the color to white on one of the loops.
This is the image I used for reference (not photographed by me):
And the result turned out like this:
The code
void setup (){size (600, 500);
noLoop();
background(65, 148, 10);
}
void draw (){
//Loop pink flower
for(int i=0; i < 7; i++){
pushMatrix();
//radomizing flower placement
translate(random(-200, 200), random(-200, 200));
//petal color
fill(255, 143, 214);
stroke(212, 87, 166);
//Petal furthest to the right
ellipse (350, 250, 100, 50);
//Petal between right and down
pushMatrix();
rotate(radians(45));
ellipse (435, -35, 100, 50);
popMatrix();
//Petal furthest to the left
ellipse(250, 250, 100, 50);
//Petal between left and up
pushMatrix();
rotate(radians(45));
ellipse(337, -35, 100, 50);
popMatrix();
//Petal furthest on top
ellipse(300, 200, 50, 100);
//Petal between top and right
pushMatrix();
rotate(radians(315));
ellipse (85, 390, 100, 50);
popMatrix();
//Petal furthest down
ellipse(300, 300, 50, 100);
//Petal between down and left
pushMatrix();
rotate(radians(315));
ellipse (-10, 390, 100, 50);
popMatrix();
// flower center
fill(255, 196, 0);
noStroke();
circle(300, 250, 26);
popMatrix();
}
//Loop white flower
for(int i=0; i < 7; i++){
pushMatrix();
//radomizing flower placement
translate(random(-200, 200), random(-200, 200));
//petal color
fill(255);
stroke(125);
//Petal furthest to the right
ellipse (350, 250, 100, 50);
//Petal between right and down
pushMatrix();
rotate(radians(45));
ellipse (435, -35, 100, 50);
popMatrix();
//Petal furthest to the left
ellipse(250, 250, 100, 50);
//Petal between left and up
pushMatrix();
rotate(radians(45));
ellipse(337, -35, 100, 50);
popMatrix();
//Petal furthest on top
ellipse(300, 200, 50, 100);
//Petal between top and right
pushMatrix();
rotate(radians(315));
ellipse (85, 390, 100, 50);
popMatrix();
//Petal furthest down
ellipse(300, 300, 50, 100);
//Petal between down and left
pushMatrix();
rotate(radians(315));
ellipse (-10, 390, 100, 50);
popMatrix();
// flower center
fill(255, 196, 0);
noStroke();
circle(300, 250, 26);
popMatrix();
}
}
I started by making one single flower in the center of the window and worked with getting the angle and placement of the petals as I wanted them. After that, I added the loop, and used translate to get the placement of the flower as a whole to change randomly. After that I colored the flowers and decided that I wanted flowers in two different colors; so I used copy-pasted the loop and changed the color to white on one of the loops.
Kommentarer
Skicka en kommentar