Code Toolkit: Python, Spring 2026

Week 3 — Wednesday, February 4 — 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 ...

Today in class we looked at Mara's homework, which you can find here: week03_mara.pyde

We read through the code trying to predict what this composition would look like. We debugged an issue in which there were two draw() blocks, which we resovled by merging them both into one.

We also talked a bit about different color systems and color spaces. If you want to use HSB mode in Processing, you can use the colorMode() command, which is documented here. Personally, I find HSB to be the much preferred color system to use when coding because of the nice way that hue allows us to specify a range of colors in the same family, and to more easily create smooth gradients. Documentation here.

Lastly, we saw how you could make a background with a dynamically changing color by using the background() command, combined with random(). You can find this code on line 36.

Thanks, Mara, 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