Over the next 10 sessions you'll become a generative artist: write the rules in p5.js, let the computer draw them, and exhibit three original pieces in a class pop-up gallery. Patterns, randomness, flowing motion and a piece that reacts to the viewer. Written by hand, no templates.
Need to log into Minecraft Education, Canva, or any other app that asks you to sign in? Most school and app accounts use the same login: your username is [email protected] (add a number if your name needs one, e.g. firstname.lastname2), and your password is the same one you use to log into your school computer.
Every project has at least one thing to hand in. Log into connect.det.wa.edu.au with your firstname.lastname and computer password, then head to your class and open the Submission section. Handing in more than one file? Zip them together first - total size must stay under 50MB.
Code, curate and exhibit a three-piece generative art collection - from your first shape to opening night.
| Criteria | Rough Sketch (0-1) |
On the Wall (2-3) |
Featured Artist (4) |
Headline Exhibit (5) |
Score |
|---|---|---|---|---|---|
| Code & Technique | Sketches incomplete or not running, no clear use of loops, colour or randomness | Three sketches run, using loops, a palette and at least one of random, noise or mouse input | All three pieces use the right technique (loops, noise, interaction), run cleanly and are commented | Code shows real problem-solving: rules that interact, deliberate glitches, and the artist can explain every block | / 5 |
| Creativity & Design | Pieces look like the code examples with little change | Own palette and layout used, pieces look different from each other | Consistent mood and palette across the collection, with a clear idea behind each piece | Distinctive, original collection where every choice of colour, pattern and movement looks intentional | / 5 |
| Curation & Presentation | Labels or screenshots missing, no hero piece chosen | Screenshots and labels done, statements explain what the pieces are | Labels and poster look professional, statements explain the rules and what the viewer does | Confident artist talk, labels that read like a real gallery, and a clear reason for the hero piece | / 5 |
| Process & Reflection | No evidence of testing or improving, reflection missing | Some evidence of trying different seeds or settings, short reflection submitted | Clear versions saved, feedback from a partner acted on, thoughtful reflection | Iteration is obvious: chosen seeds, changes based on critique, and a reflection that compares code art with hand-made art | / 5 |
| Total | / 20 | ||||
sketch.js, the Play button runs it and the preview shows your picture. New sketches also have index.html and style.css, but you will never need to touch thosesketch.js, press Ctrl+A then Ctrl+V to replace everything, then press Playfunction setup() {
createCanvas(600, 400);
background("#0d0b1f");
stroke(255, 70);
fill(255, 180);
textSize(10);
// A line every 50 pixels, with its number beside it
for (let x = 0; x <= width; x += 50) {
line(x, 0, x, height);
text(x, x + 3, 12);
}
for (let y = 0; y <= height; y += 50) {
line(0, y, width, y);
text(y, 3, y - 3);
}
}
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
fill(255, 122, 112);
circle(150, 200, 120); // circle(x, y, diameter)
fill(92, 242, 184);
rect(300, 140, 120, 120); // rect(x, y, width, height)
fill(255, 209, 102);
triangle(480, 260, 560, 260, 520, 150);
stroke(244, 241, 255);
strokeWeight(4);
line(0, 380, 600, 380); // line(x1, y1, x2, y2)
}
circle works and Circle does not.fill(255, 122, 112), a hex code like fill("#ff7a70"), and HSB numbers (hue, saturation, brightness), which are the easiest for making colours that go togetherfill() is how solid the colour is, from 0 (invisible) to 255 (solid). Overlapping see-through shapes make brand-new coloursconst palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
for (let i = 0; i < palette.length; i++) {
fill(palette[i]);
rect(i * 120, 0, 120, height);
}
}
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
fill(255, 122, 112, 150); // the 4th number is see-through-ness, 0 to 255
circle(250, 200, 240);
fill(92, 242, 184, 150);
circle(350, 200, 240);
}
function setup() {
createCanvas(600, 400);
colorMode(HSB, 360, 100, 100); // hue 0-360, saturation 0-100, brightness 0-100
noStroke();
for (let x = 0; x < width; x += 10) {
fill(map(x, 0, width, 0, 360), 80, 100);
rect(x, 0, 10, height);
}
}
80 to 30 and describe what happens to the mood.for (let col = 0; col < 12; col++) means "start col at 0, keep going while it is less than 12, and add 1 each time". Everything inside the curly brackets repeatscol % palette.length, and the % sign gives the remainder, so the colours repeat in a cyclecell to 25, then 70, and see how the whole grid changes with one numbermap() turns one range of numbers into another, so here circles get bigger as they go down the canvaspiece1-pattern-yournameconst palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
// Repeat the same circle 12 times, moving 50 pixels right each time
for (let col = 0; col < 12; col++) {
fill(palette[col % palette.length]);
circle(col * 50 + 25, 200, 40);
}
}
const palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
const cell = 50;
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
for (let col = 0; col < width / cell; col++) {
for (let row = 0; row < height / cell; row++) {
const x = col * cell;
const y = row * cell;
fill(palette[(col + row) % palette.length]);
circle(x + cell / 2, y + cell / 2, cell * 0.8);
}
}
}
const palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
const cell = 50;
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
for (let col = 0; col < width / cell; col++) {
for (let row = 0; row < height / cell; row++) {
const x = col * cell;
const y = row * cell;
// map(value, fromLow, fromHigh, toLow, toHigh)
const size = map(y, 0, height, 6, cell);
fill(palette[(col + row) % palette.length]);
circle(x + cell / 2, y + cell / 2, size);
}
}
}
cell. Then change map(y, 0, height, 6, cell) to map(x, 0, width, 6, cell) and describe how the direction of the pattern changes.random(): random(80) gives a number from 0 to 80, random(10, 80) gives one between 10 and 80, and random(palette) picks one colour from your listrandomSeed(): without it every Play makes a brand-new picture. With it, the same seed number always gives the same picture, so you can find a version you love and keep itconst palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
function setup() {
createCanvas(600, 400);
randomSeed(1); // same number = same "random" picture every run
background("#0d0b1f");
noStroke();
for (let i = 0; i < 80; i++) {
fill(random(palette));
circle(random(width), random(height), random(10, 80));
}
}
const palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
const cell = 50;
function setup() {
createCanvas(600, 400);
randomSeed(7);
background("#0d0b1f");
noStroke();
for (let col = 0; col < width / cell; col++) {
for (let row = 0; row < height / cell; row++) {
const x = col * cell;
const y = row * cell;
if (random() < 0.15) { // about 15% of cells break the pattern
fill("#ffffff");
rect(x + 8, y + 8, cell - 16, cell - 16);
} else {
fill(palette[(col + row) % palette.length]);
circle(x + cell / 2, y + cell / 2, cell * 0.8);
}
}
}
}
i < 80 to i < 300 and random(10, 80) to random(5, 30) and describe how the mood changes. Which seed goes into your final piece?random() and noise(). Random jumps anywhere. Noise glides smoothly, which is why it is used for clouds, waves, hills and flowing linesdraw(): setup() runs once, but draw() runs about 60 times a second. That repeat is what creates movementnoise() which way to face at their spot, take a small step that way, and draw a line. Together they trace an invisible current0.005 numbers in the angle line to a smaller and a bigger number (try 0.002 and 0.02) and change noiseSeed(3) to another number. Let each run for 20 seconds before you judge itnoise() and must look clearly different from Piece 1. Take your screenshot while it is still running when it looks good, because pressing Stop can clear the picture from the previewpiece2-flow-yournamelet t = 0;
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
}
function draw() {
// noise() glides smoothly between 0 and 1, so the dot wanders instead of jumping
const x = noise(t) * width;
const y = noise(t + 100) * height;
fill(92, 242, 184, 120);
circle(x, y, 14);
t += 0.01;
}
const palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
const particles = [];
function setup() {
createCanvas(600, 400);
noiseSeed(3);
background("#0d0b1f");
strokeWeight(1.5);
for (let i = 0; i < 200; i++) {
const c = color(random(palette));
c.setAlpha(60);
particles.push({ x: random(width), y: random(height), c: c });
}
}
function draw() {
for (const p of particles) {
const angle = noise(p.x * 0.005, p.y * 0.005) * TWO_PI * 2;
const nx = p.x + cos(angle) * 2;
const ny = p.y + sin(angle) * 2;
stroke(p.c);
line(p.x, p.y, nx, ny);
p.x = nx;
p.y = ny;
if (p.x < 0 || p.x > width || p.y < 0 || p.y > height) {
p.x = random(width);
p.y = random(height);
}
}
}
200 to 100 in the loop. Fewer particles still make a good flow field, they just take longer to fill the canvas.0.005 numbers changed to 0.002, and again with 0.02. Which looks like water and which looks like static? Then change 200 to 500 and describe what the extra particles do to the picture.mouseX and mouseY are where the mouse is, and mouseIsPressed is true while a button is held down. An if uses them to decide what to don for the next colour and c to clear. Click on the canvas before pressing keys so it can hear the keyboardpiece3-interactive-yournamefunction setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
}
function draw() {
if (mouseIsPressed) {
fill(255, 122, 112, 160);
circle(mouseX, mouseY, 30);
}
}
const palette = ["#ff7a70", "#5cf2b8", "#ffd166", "#8f8cff", "#f4f1ff"];
let colorIndex = 0;
function setup() {
createCanvas(600, 400);
background("#0d0b1f");
noStroke();
}
function draw() {
if (mouseIsPressed) {
// faster mouse = bigger circle
const speed = dist(mouseX, mouseY, pmouseX, pmouseY);
const size = map(speed, 0, 60, 8, 40, true);
fill(palette[colorIndex]);
circle(mouseX, mouseY, size);
}
}
function keyPressed() {
if (key === "n") {
colorIndex = (colorIndex + 1) % palette.length; // next colour
}
if (key === "c") {
background("#0d0b1f"); // clear the canvas
}
}
width - mouseX is the mirror image of mouseX. That one idea is all you need to make a drawing that mirrors itself.circle(width - mouseX, mouseY, size); under the existing circle line so everything you draw is mirrored. Then add circle(mouseX, height - mouseY, size); and circle(width - mouseX, height - mouseY, size); for four-way symmetry. Which version would you hang on a wall?Medium: p5.js code and a 2-3 sentence statementmouseX, not mousex), a missing closing bracket, or a misplaced comma// explaining each block in plain words, so anyone could follow your rulesAfter 10 sessions, from your first shape to your final artist talk, the classroom becomes a gallery. Every picture on the wall was made by rules the artist wrote, and every wall label was written by the person who wrote the code.
Then start sketching your three ideas // Session 01