Winter in Brooklyn


*currently under construction*





code︎

*click for diffrent scapes*

“winter in brooklyn” is a landscape drawing on p5js
of winter streets in Brooklyn.
This is how I’m excited about my first winter in New York︎





type: individual
date: Oct 08, 2019


Winter in Brooklyn.
This is the typical neighbourhood near where I live. 
And I wanted to draw this scene using as many as functions in p5.



1.Framing and creating vanishing point



2. Tree and for loop
original drawing of tree can be found here:
https://editor.p5js.org/mtchl/sketches/ryyW2U5Fx

I wanted to move the code of tree into a function and place them along the street.
but to make it equally distributed and easier, I put the code in the for loop.
And here is what happened with for loop.
I found out it gets stuck after drawing the first tree.
And translating origin within for loop integer hardly works.  


3. problem with arguments

So the best way I figured was to use parameter for line( ) and translate( ).

function tree(depth,startX,startY,scaleNum,sizeNum)
line(startX,startY, startX,startY-60);   // drawing the pillar of a tree
translate(startX,startY-60);
 // starting over drawing of a tree.

Here I added scaleNum and sizeNum to make trees in the back look smaller.
While I could apply them in scale(scaleNum) it didn’t work in line( ).
simply put, it was not possible to put two parameters in functions like line( ).
for example: line(startX,startY, startX,startY-sizeNum); wouldn’t work.


4. problem with noLoop( )

I also wanted an effect of snow slowly falling down.
But since I had to stop looping for random() in tree function, I couldn’t figure out the way of doing it. 



*Lesson for today:
declaring global variable with height and width doesn’t work. 
so you have to initiate in function setup() seperately.

    let h1;
    let h2;
    let w1;
    let w2;

function setup(){


    h1 = height*3/4
    h2 = height*3/5
    w1 = width*3/7
    w2 = width*4/7

}



© ymchoi 2019