-
Notifications
You must be signed in to change notification settings - Fork 6
Homework MimiY 04
Responses | Link
Questions (example questions)
- Your questions here
- Videos: Images/Video 11.1-11.8 - Focus on videos 11.1 and 11.3
- Chapter 7 in Getting Started with P5.js through Ex 7-9 | Code
- Full Resources
- Week 6 in the Syllabus
- Arrays in JavaScript | Documentation
- 2 balls, 8 variables
- 2 balls, 2 object literals
- Array of Ball() objects
- Complete the Worksheet
- Next week you will be presenting your own assignments. Time limit is 5 minutes. Be prepared to point out 3 things in your sketch and how they're working. (e.g. Here's a loop, it's limit is being set by the mouse. This doohicky is an object and I have an array of 100 of them. They flicker and change color and when I click, I flip a boolean to make them start and stop flickering.)
- Design a sketch in an object-oriented fashion. Follow these steps and see how far you get (even just doing the first couple steps is ok!)
- Make one single object with just variables.
- Put one or more functions in the object.
- Try manually making two objects.
- Duplicate the object using an array and make as many as you like!
- If you are already working with classes/objects and arrays:
- Re-organize / break-down your classes into the "smallest functional units" possible.
- Try different ways to have your objects "communicate" with each other in some way.
- In the end the goal is to have code in
draw()
that only makes calls to objects. Something like:
function draw() {
background(0);
// A single object
apple.chop();
// Another object
orange.peel();
// Calling a function on all of the objects in an array
for (var i = 0; i < grapes.length; i++) {
grapes[i].pluck();
}
}
- Videos 8.1-8.10
- More resources from syllabus
- p5.dom section of Chapter 13.4-13.6 in Getting Started with P5.js
Questions (example questions)
- What is the difference between array and arrayList? --Lulu
- How do you make multiple classes, for example, I wanted to make another type of shape that falls from the tops of the screen but wasn't sure how I could use multiple classes without getting all of the variable mixed up? -- Lizzy
- Can we go over the 'Extend' chapter? I can't figure out how to get BrowserSync working on my computer. - Pippa
- How can you make text (or something in general) only appear for a particular interval of time? Use case: have instructions appear for 10 seconds then go away. --Nikhil
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Sketch) -- any other comments
- Lulu -- MY BLOG POST, CODE OF SKETCH
- Dina -- Sketch
- Lizzy -- sketch blog
- Christina -- sketch, blog
- Na -- sketch
- Wei -- sketch,blog
- Julia -- sketch
- Wen -- sketch, BLOG
- Nikhil -- sketch blog
- Beste -- sketch
- Cy -- sketch
- Jake -- sketch, blog
- Tianjun -- sketch
- Pippa --sketch
-
RESOURCES FROM CLASS:
-
TEST YOURSELF
- Complete the Quiz
-
DO: The idea this week is to explore re-organizing your code. It is 100% legitimate to turn in a version of a previous assignment where nothing changes for the end user, but the code has been restructured. You may, however, choose to try a new experiment from scratch. Aim to keep
setup()
anddraw()
as clean as possible, and do everything (all calculations, drawing, etc.) in functions that you create yourself. Possibilities (choose one or more):- Reorganize "groups of variables" into objects. | How to do this.
- Break code out of
setup()
anddraw()
into functions. - Use a function to draw a complex design multiple times with different arguments.
- If you are feeling ambitious, try embedding a function into an object.
-
READ / WATCH
- Videos 2.3, 6.1-6.3, 7.1-7.7
- More resources and code examples
- Getting Started with p5.js chapters 10-11
-
Examples
Questions (example questions)
- How to combine two functions that should be functioned in setup() and draw() with same variables into one function?
- can we set up function which returns values with parameters, then it can be used many times in different functions?()----Wei
- I made a rollover moustache into a function, and drawing a head to put the moustache on a separate function, but no matter how I order these two things - call moustache function before/after draw head function, define moustache function before/after define draw head function - the moustache always seems to be drawing behind the head. How do I get it to draw in front of the head?? -Julia
- How can I make 4 mouse sensitive 3-d rectangles made up of lines (like my sketch but with 4 3-d squares instead of 1) - Lizzy
- What's the difference between object and class? – Na
- Adding to that, can we discuss when to have a class with behaviors vs. a function? - Christina
- Tianjun -- Sketch
- Wen -- Sketch
- Na -- sketch
- Wei--sketch
- Lulu--sketch
- Pippa-- sketch
- Julia -- Sketch
- Lizzy -- sketch
- Beste -- skecth
- Nikhil -- [Sketch] (https://editor.p5js.org/nkumar23/sketches/ZMkvb8N4b)
- Christina -- sketch, blog
- Jake -- sketch
- Dina -- Sketch
- Cy -- sketch
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: Complete Worksheet 4
-
DO: Make something with a lot of repetition, more than you want to hand-code. You could take something you've already done where there was a lot of repetition in the code 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 in the learning p5.js series.
- Getting Started with p5.js chapters 9-10
-
RUN CODE
Questions (example questions)
- Your questions here.
- What's the meaning of push and pop in p5.js.
- How do you make shapes generate and move continuously from the side of the canvas? - Lizzy
- Can you explain the floor() function? – Na
- Is it possible to generate a random color inside a loop without making the color blink? – Na
- My web editor crashes a lot and I have to start my sketch over. Any tips? – Cy
- How can I work within shades of a color? Can you loop things that are individually drawn out? - Pippa
- Lulu -- The roof by lulu, Code
- Wen -- blog post, Sketch
- Lizzy -- sketch
- Tianjun -- sketch
- Na - sketch
- Christina -- blog post, sketch
- Beste -- blog, sketch
- Wei -- sketch,blog
- Pippa - sketch, blog
- Nikhil - sketch, blog
- Jake - sketch, blog
- Cy - sketch
- Dina -- Sketch
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: Complete Worksheet 3
-
DO: In general this week, you should work with rule-based animation, motion, and interaction. You can use the ideas below or invent your own assignment. Start by working in pairs as below. Can you divide an idea into two parts and combine those parts? (e.g. One of you codes the input behaviors and the other one codes the output behaviors.) Can you swap sketches and riff of of your partner's work? You can post together or break off and complete the assignment individually.
- Try making a rollover, button, or slider from scratch. Compare your code to the examples on github. Later we'll look at how this compare to interface elements we'll get for free from the browser.
- Tie the above two together and have an interface element control the visual design or behavior of other elements in your sketch.
-
READ / WATCH
- Videos 4.1-4.2 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
Questions (example questions)
- When I set up a bouncing ball which will change direction when it hits a moving target, the bouncing ball will stop and "shake" for a while and then moves back.Don't know how to stop the "shaking"------Wei
- Is there a way to switch back to your original variable values without redefining them again? -- Jake
- Also, please please please tell me there is some trick to make translate and rotate make more sense. I keep loosing my objects when I rotate them and they end up off the canvas. -- Jake
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Sketch) -- any other comments
- Julia & Lu - Sketch with rollovers and buttons
- Lizzy & Wen - Click and Button, LC Blog, Wen Blog
- Christina & Dina - Sketch
- Nikhil & Beste - Sketch 1, Sketch 2, NK Blog, B Blog
- Wei & Jake-WK blog, Jake blog, sketch
- Na & Pippa - sketch, Na's blog, Pippa's blog
- CY & Tianjun - sketch
-
LINKS FROM CLASS:
-
TEST YOURSELF: Worksheet Post a url to your answers on the Google Doc.
-
DO: Create a sketch that includes (all of these):
- One element controlled by the mouse.
- One element that changes over time, independently of the mouse.
- One element that is different every time you run the sketch.
- e.g. Try refactoring your Week 1 HW by removing all the hard-coded numbers except for createCanvas(). Have some of the elements follow the mouse. Have some move independently. Have some move at random.
- e.g. Do the above but change color, alpha, and/or strokeWeight instead of position.
- Or do something completely different!
-
WATCH, READ, RUN CODE:
Questions (example questions)
- I always can't remember the meaning of my variables. Lulu
- Why must "let r=random(255)" be put inside a function, not outside? – Na
- How to change the rate of the draw function ran per second? The eyebrow in my sketch shaked too anxiously after I put a random function into that.Maybe the problem is with the rate of the random function generate a new random number.
- How can I embed my P5.js sketch into my squarespace blog? - Pippa
- What does "Script error.(:line 0)"means? It happens when I set up wrong declares. - Wei Kang
- How can I make a grid of ellipses disperse in many directions when I move the mouse rather than all moving in unison (as my sketch)? - Lizzy
- Is it possible to initialize variables at the same time? (for example, x, y, i = 0) - Christina
- How do you move multiple shapes towards the mouse without them all converging to the center? - Jake
- How do you use scale() function to enlarge an object(s) over time? - Jake
- Boaty McBoatface -- [blog post](url to blog), zoog -- any other comments
- Lulu -- work post
- Wen -- blog post, work post
- Dina -- Blog post Work post
- Na -- sketch
- Tianjun--sketch
- Pippa -- sketch, blog post
- Wei Kang -- sketch_week2,blog
- Lizzy -- sketch blog
- Julia
- Beste -- blog,sketch
- Cy Statham -- sketch, blog post
- Nikhil Kumar - sketch, blog
- Christina Dacanay - sketch, blog
- Jake Sherwood - sketch, blog
-
RESOURCES FROM CLASS:
-
SET UP:
- Sign up for the ITP ICM Google Group
- 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.
- Create your own screen drawing: self-portrait, alien, monster, etc. Use 2D primitive shapes –
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 a sample example: Zoog - Write a blog post about how computation applies to your interests. This could be a subject you've studied, a job you've worked, a personal hobby, or a cause you care about. What projects do you imagine making this term? What projects do you love? (Review and contribute to the ICM Inspiration Wiki page). In the same post (or a new one), document the process of creating your sketch. What pitfalls did you run into? What could you not figure out how to do? How was the experience of using the web editor? Did you post any issues to github?
-
READ AND WATCH:
-
Watch before homework: Videos 1 - 7 | Watch after homework: Videos 2.1 - 2.3
- If YouTube bothers you, ask Daniel Shiffman for a link to videos on Google Drive.
- 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.
-
Watch before homework: Videos 1 - 7 | Watch after homework: Videos 2.1 - 2.3
-
ASK QUESTIONS: Contribute at least 1 question below.
Questions | Examples
- your question, your name
- How to change the size of a triangle?, Dina
- I cannot understand that Why I should write command like ‘fill(0)’ ‘noStroke()’ before the command of ‘rect()’ if I want to change the setting of the rectangle. Lu Lyu
- How to put same elements in sequence without using copy and paste?----Wei Kang
- Is there a way to have a stroke/outline around only part of a shape? -Julia
- Is there a way to have all elements scale in relation to the canvas size? -Christina (I guess map(); will help you a lot! - Wen)
- How do you rotate a shape? – Na (You can use rotate() to rotate it. - Wen)
- Can you do a demonstration about arc? – Na
- How do you fill the shape with pattern or image instead of color? - Wen
- How to control the size of the processing sketch when it is embedded into a website? Can it be realized through some instructions in P5.js? -Tianjun
- Can you talk about when to use Bezier curves and when regular curve functions are better, especially when making custom shapes? - Nikhil
- How does ellipseMode(CENTER); work? - Lizzy (It means that the coordinate point will be set on the center of the ellipse, actually I think it's an easier way to draw an ellipse! - Wen)
- How can you rotate objects and make arcs without PI? Also, why when I move different parts of my drawing around are other aspects moved? - Pippa
- Boaty McBoatface -- [blog post](url to blog), zoog -- any other comments
- Lu, Lyu-- https://wp.nyu.edu/jiaolyulu/2019/09/06/icm-week1/
- Wei Kang -- blog_week1_post, blog_week1_sketchnote,self_portrait
- Beste Saylar -- https://www.bestesaylar.com/icm-blog -- https://editor.p5js.org/bestesaylar/sketches/lSyqxth11
- Dina Khalil -- https://editor.p5js.org/dinakhalil1/sketches/aPcxkoR_6 -- https://dinashkhalil.wixsite.com/blog/post/icm-1
- Julia Campbell - https://editor.p5js.org/notoriousblt/sketches/atWzCoje2
- Kuan-Wen Chen - drawing, blog post
- Christina Dacanay- sketch, blog post, response
- Na Chen - drawing, documentation, blog
- Cy Statham drawing, blog post
- Lizzy Chiappini drawing, blog post 1, blog post 2
- Tianjun Wang-- https://wp.nyu.edu/vessel/2019/09/06/icm-homeworkweek1/
- Nikhil Kumar sketch, intro blog, sketch process blog
- Pippa Kelmenson - drawing, reflections & computation
- Jake Sherwood sketch, intro blog, sketch process blog, general icm blog
-
RESOURCES FROM CLASS:
-
TEST YOURSELF: Complete Worksheet 4
-
DO: Make something with a lot of repetition, more than you want to hand-code. You could take something you've already done where there was a lot of repetition in the code 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 in the learning p5.js series.
- Getting Started with p5.js chapters 9-10
-
RUN CODE
Questions (example questions)
- Your questions here.
- Your Name -- [Title of Blog Post](Link to Blog Post), [Title of Sketch](Link to Sketch) -- any other comments