Title: School’s Library
Link: https://editor.p5js.org/LafouCC/sketches/HF9cUzJV7
Video:
Description: I got inspired by a photo that I took which is a school library in DC. Since I have done some similar tasks when I was using Processing, I wanted to try something that is more challenging. So instead of drawing a 2D picture, I decided to try 3D and explore how to make my picture more realistic. So I tried to draw a realistic tree by learning related videos online. See those learnings in the next part.
Coding:
(1) 3D:
In order to create gradients, I utilized some knowledge from calculus and the concept of acceleration from physics. By breaking down the surface into multiple rectangles with a change of colors using “for” loops, I achieved what I want.
for (let i=1;i<50;i++){ fill(130+i*2); rect(625+i*3,218+i*2*(100-i)*0.01,3,270); }
(2) recursive tree:
I learned from a youtube video:
https://www.youtube.com/watch?v=-3HwUKsovBE
So the concept is using recursion, I create another similar function called branch(). See as below:
function branch(len){ stroke(0); push(); if (len>4){ strokeWeight(len*0.15); line(0,0,0,-len); translate(0,-len); rotate(random(25,35)); branch(len*random(0.6,0.8)) rotate(random(-50,-70)); branch(len*random(0.6,0.8)) } pop(); }
Reflections:
- Did you prefer exploratory programming, or using the reference? Why? Could you imagine a situation where you would use the other technique?
I prefer using the reference. Because using the reference is more efficient and more accurate. You can learn the meanigs of different parameters. But sometimes, I will use exploratory programming after learning the reference, because it can deepen my understanding as “practice makes perfect”.
- In which ways (if any) was drawing on a piece of paper (as we did in our exercise) easier than writing the program?
Drawing on paper is easier to learn than coding, and people can easily draw some complex curves or shapes without thinking about how to achieve that through codes. Coloring the picture is also easier because people don’t need to use the color selector and try to find that color.
- In which ways (if any) is writing the program easier than drawing on the piece of paper?
Writing the program is more efficient. People can create different functions that can be called many times. Also, utilizing “for” loops can help to simplify the process of drawing.
Writing the program can infuse motions into pictures, and it can make animation easily.