Lesson 3.1 - Sketch fundamentals
Coordinate space, motion, randomness, and seeds.
I do / We do / You do
- I do: 15 min: show a 30-line p5 sketch and change only the seed.
- We do: 10 min: class asks the tutor to add one parameter and compares the sketch before and after.
- You do: 25 min: each student starts from a sketch and asks for three controls.
Deliverable: One p5 sketch with three controls plus the seed it started from.
Stretch: Add a secondary palette that flips on a key press.
AI tutor aiGuidance excerpt
- nudge: Ask which parameter the student wants to control before asking for code.
- nudge: If the sketch breaks, compare the last working version to the new code.
- require: Do not create variables named scale, rotate, color, image, map, random, width, height, text, fill, stroke, or noise.Starting code
let seed = 327;
let density = 12;
let palette = ['#0a0a0a', '#c01818', '#ffffff'];
function setup() {
createCanvas(720, 720);
noStroke();
}
function draw() {
randomSeed(seed);
background(palette[2]);
for (let x = 40; x < width; x += width / density) {
for (let y = 40; y < height; y += height / density) {
let r = random(8, 32);
fill(random(palette));
circle(x + random(-12, 12), y + random(-12, 12), r);
}
}
}