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?

[An orange and dark blue sunset with orange twinkling stars. Link to p5 editor with code: https://editor.p5js.org/zoemargolis/sketches/FX8FXdBfn](https://editor.p5js.org/zoemargolis/full/FX8FXdBfn)

An orange and dark blue sunset with orange twinkling stars. Link to p5 editor with code: https://editor.p5js.org/zoemargolis/sketches/FX8FXdBfn

Worksheet:

  1. Organize the example Zoog portrait into functions so that you can understand what it’s doing without right comments and you can easily turn different parts of the sketch on/off by commenting in/out calls to your functions.
    1. https://editor.p5js.org/zoemargolis/sketches/gGhCv7KYq
  2. Take one of the functions from your re-factored Zoog portrait and re-write it so that you can call the same function twice and have it draw slightly different versions of the same thing. (e.g. Draw a big eye. Draw a little eye.) Alternatively you can try doing this on your own self-portrait.
    1. https://editor.p5js.org/mpm9038/sketches/ewnTP4qEo
  3. Define a portable function that adds two numbers together and returns the sum. You should be able to copy and paste this function definition and only this function definition into a different sketch and use it without creating errors.
    1. https://editor.p5js.org/zoemargolis/sketches/UrhEgVUg2
  4. Re-organize your bouncing ball code from Week 3’s quiz into at least 2 functions. Challenge: Create a reusable bounce() function that can be used to bounce positions, colors, anything you can think of.
    1. https://editor.p5js.org/zoemargolis/sketches/pwYUC-r_A