-
Notifications
You must be signed in to change notification settings - Fork 0
Homework Mimi 04
-
RESOURCES FROM CLASS:
-
TEST YOURSELF
- Complete the Worksheet
-
DO: Functions are the basic unit of labor in your code. Take a sketch you’ve already done and re-organize the code into functional units of labor that you define. You can also conceive of an entirely new world of labor. What kinds of labor does it take to make your sketch run?
- Take time to name your functions well. In class we will comment out function calls one at a time and see if we can predict what will stop working.
- Aim to keep
setup()anddraw()as clean as possible, and do everything (calculations, drawing, etc.) in functions that you define. - Challenge goal: Write a re-usable function, a function you can call in multiple ways to do the same thing slightly differently each time.
-
READ / WATCH
- Video 2.3 on JavaScript Object Literals (~10m)
- Videos 6.1-6.3, 7.1-7.7(~2h)
- More resources and code examples
- Getting Started with p5.js chapters 10-11
-
Examples
-
ASK
- Post at least 1 question here. Need help on asking a question?
- Yuyuan -- For worksheet Q3 ,Why can a function return result of an operation, such as a + b, directly without first creating a variable such as Sum? Detailed question in blog
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Sketch) -- any other
- Colin -- CTP BLOG W5
- Yuyuan --ICM Bolg,reorganized code
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: Complete Worksheet 4
-
DO: Our ability to see patterns is what makes us human. However we also see patterns where none exist because our brains are biased towards detecting certain kinds of patterns over others (e.g. faces). Create a pattern by making something with a lot of repetition. Is the resulting pattern easy to see or hard to see? What would it mean to create the illusion of pattern? Can you predict what the pattern will be when you run your code or does it surprise you? You could take something you've already done where there was a lot of repetition in the code (e.g. your self-portrait) and see if you can re-write it using a loop so that instead of 28 lines of code that call rect(), you have 1 line of code calls rect() inside of a loop that goes around 28 times. How do you need to rework the way you position that rect() in order to make it work in a loop? Try creating an algorithmic design with simple parameters. (One example is 10PRINT, example code).
-
READ / WATCH
- Videos 5.1-5.3(~40min) in the learning p5.js series.
- Getting Started with p5.js chapters 9-10
-
RUN CODE
-
ASK * Post at least 1 question here. Need help on asking a question?
- Name (optional): Question
- Shelby: For the 'while' loop, why did I have to put the c variable's initial value where I did (line 35), instead of where I originally thought I should put it (in the setup loop on line 26)? https://editor.p5js.org/sa-ITP/sketches/tocpUSo5X
- Kate: I have a question on my blog about which way of writing code is better
- Yuyuan: For worksheet Q2(a), I was trying to skip column #7. I expected the 7th row to be skipped when columnN == 7 and on == false, but instead, nothing was displayed. Here is my incorrect code .
*Doha: If shapes follow a clear pattern, you can easily arrange them with a loop. But what if you want to create an irregular arrangement? You can use random(), but then you don't have much control over the composition. Is there a way to use a loop to create irregular positions or shapes while still having control over the result?
- Colin: A fill effect happens when I change addition to multiplication in line 21 of my FOR Loop link (if(mouseX>=C20 && mouseX<=C20+20) -> if(mouseX>=C20 && mouseX<=C20*20)) (https://editor.p5js.org/ColinTP/sketches/Vsj2AHJ2a) why does this happen?
- Siyin: Question: 1. When I want shapes/behaviors to change according to both mouseX and mouseY, how to divide up the conditionals? currently I have if (x<400) { if (y<400){do A}; if (y>400){do B} }; else if (x>400) { if (y<400){do C}; if (y>400){do D} }; which feels redundant. Is there a way to simplify this logic? This question is related to my creative assignment. 2. As our functions become more complicated, could we clarify when to console.log? eg. inside/ outside a loop, inside/ outside a conditionals.
-
Kate -- Blog, Tomato farm
-
Yuyuan--ICM Week4,Bird Patern
-
Shelby -- Week 4: Alphabet Pattern, expanding on an interesting mistake from the worksheet
-
Hanna Week 4 blog Pumpkin Parade
-
Shengzhe -- Week 4 Blog, P5
-
Colin Blog4
-
Yulan -- Blog Week 4, Mushroom
-
Shuyu --Blog Week 4. [Random Face] (https://editor.p5js.org/LinSHU0901/sketches/enyEYBhlC)
-- any other comments
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: Complete Worksheet 3
-
DO: Two roads diverged in a yellow wood, And sorry I could not travel both... Life is full of difficult choices, use conditional statements to control the flow of your programs. Create a sketch that asks people to make difficult choices that have surprising consequences.
- Which choices are easier, harder? Which choices are false choices?
- What internal or external factors influence the choice? How do others’ choices affect your choices?
- What choices surprise you with unexpected outcomes?
- Can you combine choices to create hard-to-predict results? (Hint: Use && and ||)
- Work in Pairs Can you divide an idea into two parts and combine those parts? (e.g. One of you codes the input behaviors (if statement) and the other one codes the output behaviors (what to do if it’s true.) Can you swap sketches and riff off of your partner's work? Provide 1 sketch link per pair, however clearly describe who did what in the code.
-
READ / WATCH
- Videos 4.1-4.2(~25min) in the learning p5.js series. | Code
- Chapter 4.5-4.13 of Getting Started with p5.js book | Ebook (free with NYU Library login) | Code
-
ASK
- Post at least 1 question below. Examples of good questions... Siyin- How to comment out multiple rolls of codes at once? I tried to highlight multiple rolls and type "//", it didn't work.
in one attempt, I declared and initialized a variable in two lines: let ON; let ON=false. there's a false notification saying "this variable is already been declared". Why is that so?
Yuyuan- For worksheet Q2 I use reset = !reset, the state keeps toggling every frame while the mouse stays over the column, causing flickering. Is there a way to make it change only once each time the mouse enters the area?
- Colin - What's the difference between using "var x = 0" and "let x = 0"? Both "var" and "let" seem to function very similarly.
-Doha : Is it possible to include a clickable hyperlink in a code comment? I like to leave references in my homework so I can remember where I learned a particular part of the code. It would be helpful if I could click the URL in the comment and go directly to the source.
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Code) -- any other comments
- Siyin-- Week 4 blog, very inspired!, [Charging Laptop], (https://editor.p5js.org/ade-triphosphate/sketches/NLcwILKvc). I'm very inspired by this week's boolean variables. It means a state, and it is more abstract than numeric coordinates, shapes, or colors. Also, console.log is very useful when it comes to using multiple boolean variables to create things.
- Kate - Blog Kate & Hannah sketch: Pick your gift
- Yuyuan -ICM Week3 Blog, moon&sun
- Doha Blog Colin&Doha
- Shengzhe & Shelby - Group Work
- Hanna Week 3 Blog
- Yulan -- ICM week3,[Charging Laptop], (https://editor.p5js.org/YulanS/sketches/n1VkcXTcx)
- Colin -- W3 Blog
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: (Only use what we've learned so far: calling p5 functions and variables.) Worksheet ONLY POST WORK YOU WANT ME TO LOOK AT
-
DO:
- Consider the following cliches / pearls of wisdom: No man is an island. There is no such thing as a new idea. Everything is related to everything else. It’s all relative. The world is defined through relationships and those relationships shape our perspectives. Use variables to build in some relationships between two or more elements in your sketch and think about how the perception of what’s happening is different depending on which element's perspective you take on. Think about:
- What’s related to what?
- How are they related?
- Is it a positive or negative relationship? Example sketch.
- Is it an amplifying or diminishing relationship? Example sketch.
- You should definitely take a mathematical approach to answering these questions but you can also take a figurative, metaphorical approach.
- The elements common to all of your sketches are: position, dimensions, stroke thickness, color values. Can you relate one or more of these elements to:
- itself over time (so it changes over time)
- a different element in your sketch
- frameCount (which frame of animation is now)
- mouseX or mouseY or the combined (mouseX, mouseY) mouse position
- or something else!
- You can revisit your self-portrait to build relationships between features OR create something new.
- Consider the following cliches / pearls of wisdom: No man is an island. There is no such thing as a new idea. Everything is related to everything else. It’s all relative. The world is defined through relationships and those relationships shape our perspectives. Use variables to build in some relationships between two or more elements in your sketch and think about how the perception of what’s happening is different depending on which element's perspective you take on. Think about:
-
WATCH, READ, RUN CODE:
- Watch Conditionals 3.1 - 3.4 ~1hr
- Getting Started with p5: Chapter 5 (Response). | Chapter 5 Code
- Go further with Transformations (Optional)
- Transformations Video Tutorials
- Getting Started with p5: Chapters 6 (Transformations) and 8.10-8.15 (More complex motion)
-
ASK
- Post at least 1 question below. Examples of good questions...
- Kate: when I set width of rect to correlate to sin, why is it not a smooth change, but stepped (I figured out)
- Shelby: Is there a "dist();" for angles? OR can "dist" work with angles? (I have a feeling I still have a fundamental misunderstanding about PI and ellipses, lol.) Basically, I'm wondering if there's a simple way to calculate the locations of the intersections of the two ellipses here: [https://editor.p5js.org/sa-ITP/sketches/urIh2_VfE](https://editor.p5js.org/sa-ITP/sketches/urIh2_VfE)
- Colin: What's the purpose for having the 5th or 8th arguments in a rect() function? Furthermore, the triangle() function moves weirdly compared to ellipse() and even more so than rect(), why is that?
*Doha — In the tutorial videos, I noticed that sometimes let is used to declare a variable, while other times var is used. Is there an important difference between them? The videos seemed to suggest that they work slightly differently, but I am still not sure exactly how they are different or when I should use each one.
- Hanna — Why does my transparent light look different when background() is in draw() instead of setup()?
- Yulan - When a circle moves diagonally by changing both its x and y positions, why does it appear to move faster than a circle moving only horizontally or vertically? How can I make all the circles move at the same actual speed?
- Siyin: How do I create a line rotating according to the direction of the mouse while not changing the length of that object?
- Boaty McBoatface -- [blog post](url to blog), [zoog]
- Shelby Arnold -- blog post, sketch
- Colin T-P -- ColinTP Blog Week 2
- Yuyuan Jia --ICM Week1 Blog, self portrait2.0
- Kate -- Blog, Relatively Mondrian
- Doha -- Doha's Blog W2, Self Portrait 2
- Hanna -- Hanna's ICM Blog — Week 2, [Week 2 - Self Portrait]
- Yulan -- Blog, self portrait
- Shengzhe Xu -- Blog
- Siyin Animation 1, blog(not fully done)
-
RESOURCES FROM CLASS:
-
SET UP:
- Sign up for a Github Account. You need it to edit this wiki page.
- Log into a p5.js web editor account with your github account.
-
DO:
- Complete this worksheet. Our weekly worksheet become the basis for the next class. You must be logged in with your NYU account to access the worksheet. ONLY POST WORK YOU WANT ME TO LOOK AT
- Create a "self" portrait using 2D primitive shapes. Play with symmetry in your portrait. Shapes include –
arc(),curve(),ellipse(),line(),point(),quad(),rect(),triangle()– and basic color functions –background(),colorMode(),fill(),noFill(),noStroke(),stroke(). Remember to usecreateCanvas()to specify the dimensions of your window and wrap all of your code inside asetup()function. Here's an example: Zoog - Write no more than 5 sentences about how computation applies to your interests, due 24 hours before the next class. Pick one of the following to address (a,b, or c):
- Something you studied, a job, a hobby, or a cause you care about.
- Describe a project you want to make. Why do you want to make it?
- Describe a project your love. What do you appreciate about it that others don't always immediately get? (You can review and contribute to the ICM Inspiration Wiki page).
- In the same post (or a new one), point to one thing in your code that you'd like us to talk about in class. Cite the line number(s). Be prepared to talk about why it's interesting to you.
-
READ AND WATCH:
- Follow the TO THE LESSON Link:
- Watch before HW: Videos 1.1 - 1.6(~1h 15m)
- Watch after HW: Videos 2.1 - 2.3(~30m)
- If you prefer books, Chapters 1-3 of Getting Started with p5.js cover the same material. Log into the NYU network to read it for free.
- Follow the TO THE LESSON Link:
-
ASK
- Post at least 1 question below. Examples of good questions...
- Name (optional) -- Question: Why is it that this is like this and that is like that?
- Kate -- What's the difference of putting "let x = 50;" inside and outside of draw()?
- Colin -- What commands can be typed to rotate a shape, or an image?
- Doha -- Is there a way to group multiple shapes together so that you can move or resize the entire object at once instead of changing each shape individually?
- Shelby -- Why does the "arc" function use radians and not degrees?
- Steven -- Why does putting x++; in a different place cause the square to stop moving?
- Yulan -- Why does the square seem to disappear when I move the if (mouseX > x && mouseX < x + 50) statement before rect(x, 200, 50, 50), but reappear when the mouse reaches it?
- Hanna --Why does a transparent color become darker over time when I use fill(R, G, B, alpha)
Please make sure your posts are publicly accessible by testing them in an Incognito (Chrome) or Private Browser (Safari).
- Homework Links
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Sketch) -- any other
- Kate -- ICM Week 1 Blog, Self portrait
- Colin -- ICM Week 1 Blog, Self Portrait
- Steven -- ICM Week 1 Blog, Self portarit
- Doha -- [1st] ICM_Week 1_090326, Self Portrait
- Shelby -- ICM Week 1, ICM: Week 1 Assignment - Self Portrait
- Yuyuan-- ICM Week 1 Blog, Self Portrait
- Yulan -- ICM Week1, Self Portrait
- Hanna -- ICM Week 1, Self Portrait
- Siyin Yan-- https://editor.p5js.org/ade-triphosphate/sketches/XpjSfnqL5