Code Toolkit: Python, Fall 2025

Week 3 — Wednesday, September 10 — Class notes

  1. Review of last week
  2. Homework review
  3. Interaction
  4. Adding interactivity with Processing
    1. New syntax: setup() and draw() blocks
    2. New command print(), and string concatenation
    3. A rectangle that moves with the mouse
  5. More interaction concepts
    1. Framerate
    2. Scope
    3. Asking "when?": How to use setup() and draw()
    4. pmouseX and pmouseY
  6. New command: map()

I. Review of last week

II. Homework review

Let's look at some people's homework and fix some bugs together ...

In class we reviewed Clementine's homework, which you can find here. We didn't need to change too much about this. We used find & replace to change all instances of windowW with width and windowH with height — because these variables get set automatically when you call size().

We also added transparency to a few additional colors, and talked about how this sketch effectively uses variables and arithmetic to create a dynamic composition in which changing one variable changes the entire thing proportionally.

Probably the most important thing I talked about when reviewing this was that the name of a sketch much always match the name of the folder that contains it — and if you do not do this, Processing will try to create a new subfolder for you, which can be confusing. So try to make sure your sketch file and folder names are the same.

Thanks, Clementine, for sharing!

(jump back up to table of contents)

III. Interaction

(jump back up to table of contents)

IV. Adding interactivity with Processing

(jump back up to table of contents)

V. More interaction concepts

(jump back up to table of contents)

VI. Map