- Learnt28 min · run without screen refresh, numbers on keys
- Basic24 min · the pattern machine
- Challenge 1–327 min · stops, a surprise key, a gallery
- Extrabonus · save your own designs, and ship it
Review — Lesson 7 5 min
- Draw a shape, turn, draw it again — and you get a pattern.
- The pattern closes when copies × turn = 360.
flower (petals) (sides) (size) :: customcalls your polygon block.
Quick-fire
A flower has 9 petals. How far does the arrow turn between petals?
Reveal the answer
40 degrees. 360 ÷ 9 = 40.
Today’s Topic 3 min
- Run without screen refresh — a block that finishes before the Stage is shown
- Variables on keys, and a
redrawblock - A gallery of designs kept in lists
- Shipping the project so other people can play it
Learning outcome
By the end of this lesson you will be able to:
- Explain what Run without screen refresh changes.
- Change a drawing with keys and redraw it at once.
- Save and load settings using lists.
Learnt — make it fast, then make it a toy 28 min
1 · A slow spirograph
A circle is a polygon with lots of sides. Draw 24 circles, turning 15 degrees between them, and you get a spirograph — the pattern from the toy with the gear wheels.
repeat (24)
polygon (20) (12) :: custom
turn cw (15) degrees
change pen (color v) by (4)
end
How to use this: Click the green flag and watch the timer in the corner.
2 · Run without screen refresh
Normally Scratch draws the Stage again after each step of a loop, so you can watch. That is why everything so far has been slow enough to see. You can switch that off for a My Block:
- Right-click your
definehat and choose Edit. - Tick Run without screen refresh. Click OK.
- Now the whole block finishes first. The Stage shows only the end result.
define spiro
erase all
set pen size to (2)
set pen (color v) to (hue)
pen up
go to x: (0) y: (0)
point in direction (90)
pen down
repeat (24)
polygon (20) (12) :: custom
turn cw (15) degrees
change pen (color v) by (4)
end
pen up
when [space v] key pressed
change [hue v] by (20)
spiro :: custom
How to use this: Click the green flag, then press the space key a few times.
3 · Numbers on keys
Put the flower’s numbers into variables. A key changes a variable, then calls redraw. Because redraw runs without screen refresh, the new pattern appears straight away.
define redraw
erase all
pen up
go to x: (0) y: (0)
point in direction (90)
pen down
set pen (color v) to (hue)
flower (petals) (sides) (size) :: custom
pen up
when [up arrow v] key pressed
change [petals v] by (1)
redraw :: custom
when [right arrow v] key pressed
change [sides v] by (1)
redraw :: custom
Basic — the pattern machine 24 min
Open your project with the polygon and flower blocks.
Step 1 — the variables
- Make four variables:
petals,sides,sizeandhue. - Tick
petalsandsidesso they show on the Stage.
Step 2 — the redraw block
- Make a Block called
redraw. Tick Run without screen refresh. - Build the redraw stack from the Learnt.
Step 3 — the flag
- Under the flag:
set pen size to (2). - Set petals to 12, sides to 5, size to 50 and hue to 80.
- Call
redraw :: custom.
Step 4 — the keys
- Up arrow: petals goes up by 1, then redraw.
- Down arrow: petals goes down by 1, then redraw.
- Right arrow: sides goes up by 1. Left arrow: sides goes down by 1. Both redraw.
when flag clicked
set pen size to (2)
set [petals v] to (12)
set [sides v] to (5)
set [size v] to (50)
set [hue v] to (80)
redraw :: custom
when [down arrow v] key pressed
change [petals v] by (-1)
redraw :: custom
when [left arrow v] key pressed
change [sides v] by (-1)
redraw :: custom
How to use this: Click the green flag. Press the up and down arrows to change petals, left and right to change sides.
Each key press draws slowly.
Run without screen refresh is not ticked on redraw. Right-click the define hat, choose Edit, and tick it.
The new pattern is drawn on top of the old one.
erase all is missing from the top of redraw.
The pattern jumps around the Stage.
Redraw must travel back to x: 0, y: 0 and face 90 before it draws, every time.
Dials with stops
A real dial cannot turn for ever. Give yours stops, and add a size dial.
- Petals stay between 3 and 24.
- Sides stay between 3 and 10.
- W makes the pattern bigger and S makes it smaller, in steps of 5, between 20 and 70.
- Show size on the Stage too.
How to use this: Click the green flag. Use the arrow keys, then W and S. Keep pressing down to find the stop.
Teacher reveal
when [w v] key pressed
if <(size) < (70)> then
change [size v] by (5)
end
redraw :: custom
Every key gets the same shape: check the limit, change, redraw.
The surprise key
Press R and the machine invents a pattern for you.
- R picks random petals (5 to 20), sides (3 to 8) and size (25 to 55).
- R picks a random colour too.
- The boxes on the Stage show what was picked.
How to use this: Click the green flag, then press R again and again.
Teacher reveal
when [r v] key pressed
set [petals v] to (pick random (5) to (20))
set [sides v] to (pick random (3) to (8))
set [size v] to (pick random (25) to (55))
set [hue v] to (pick random (0) to (100))
redraw :: custom
A gallery in lists
Keep four favourite designs in three lists — one for petals, one for sides, one for size. Row 1 of every list is design 1, row 2 is design 2, and so on.
- Make lists
g petals,g sidesandg sizewith four rows each. - Keys 1, 2, 3 and 4 show that design.
- A box on the Stage says which design is showing.
How to use this: Click the green flag, then press the keys 1, 2, 3 and 4.
Teacher reveal
define show design (n)
set [design v] to (n)
set [petals v] to (item (n) of [g petals v])
set [sides v] to (item (n) of [g sides v])
set [size v] to (item (n) of [g size v])
set [hue v] to ((n) * (25))
redraw :: custom
when [2 v] key pressed
show design (2) :: custom
Three lists kept in step is Level 3’s Card Battle idea. If a pupil’s designs come out mixed up, one list has a row too many.
Save your own designs — and ship it
Let the player fill the gallery. Then share the project so other people can play.
- The flag empties the gallery lists and draws a starting pattern.
- The arrows design a pattern. S saves it to the end of the lists.
- A
savedbox shows how many designs are saved. - Keys 1, 2 and 3 bring back a saved design — but only if it exists.
- The arrow tells the player which keys to use.
How to use this: Click the green flag. Use the arrows to design, S to save, then 1, 2 or 3 to bring a design back.
Teacher reveal
when [s v] key pressed
add (petals) to [g petals v]
add (sides) to [g sides v]
add (size) to [g size v]
set [saved v] to (length of [g petals v])
say (join [Saved as design ] (saved)) for (1.5) seconds
when [3 v] key pressed
if <not <(length of [g petals v]) < (3)>> then
set [petals v] to (item (3) of [g petals v])
set [sides v] to (item (3) of [g sides v])
set [size v] to (item (3) of [g size v])
redraw :: custom
end
Summary 5 min
- Run without screen refresh makes a My Block finish before the Stage is shown.
- Never put a wait or a forever inside a block that runs without screen refresh.
- Keys change variables; one redraw block draws the result.
- Lists kept in step can hold a whole gallery of settings.
- Screen refresh
- Scratch showing the Stage again. Normally it happens after every step of a loop.
- Generator
- A program that makes new things from a few settings.
- Spirograph
- A pattern of circles turned round a centre, like the toy with gear wheels.
Hand in
Share your pattern machine and keep the link. That is the end of Geometry Art. Next lesson a new arc begins: Music Maker, where code plays the notes.