- Learnt28 min · the mirror sum, a second pencil, getting it ready to share
- Basic25 min · the finished Sketch Pad
- Challenge 1–327 min · a mirror switch, four ways, a start card
- Extrabonus · a kaleidoscope of clones
Review — Sketch Pad III 5 min
change pen (color v) by (2)makes a rainbow line.- An eraser is a white pen. A stamp prints the costume.
- A
toolvariable holds a word, and the loop asks it before drawing.
Quick-fire
A pencil is at x: 80, y: 20. Where is the point that matches it on the other side of the Stage, the same distance from the middle?
Reveal the answer
x: −80, y: 20. Same height, same distance from the middle, other side. That one minus sign is today’s whole trick.
Today’s Topic 3 min
- The mirror sum:
((0) - (mouse x)) - A second pencil that draws the mirror image
- Two sprites that hear the same message
- Getting an app ready for someone else to use
Learning outcome
By the end of this lesson you will be able to:
- Work out a mirrored position with one subtraction.
- Make two sprites draw at once from one mouse.
- Finish an app so that a new user knows what to do.
Learnt — two pencils, one hand 28 min
1 · The mirror sum
The middle of the Stage is x: 0. A point at x: −100 is 100 to the left. Its mirror is 100 to the right, at x: 100. The y does not change.
So the mirror of any x is ((0) - (x position)). Try it: 0 − (−100) is 100. 0 − 60 is −60.
How to use this: Click the green flag to start it. Nothing else to press — watch the faint pencil copy the left half of the heart.
2 · A Mirror pencil
- Right-click the Pencil and choose duplicate. Rename the copy Mirror.
- Delete the Mirror’s key scripts. Keep its green-flag script.
- Swap its
go to [mouse-pointer v]forgo to x: ((0) - (mouse x)) y: (mouse y). - Give it
set [ghost v] effect to (50), so you can tell the two apart.
when flag clicked
go to [back v] layer
set pen color to [#4C4CFF]
set pen size to (4)
set [ghost v] effect to (50)
forever
go to x: ((0) - (mouse x)) y: (mouse y)
if <<mouse down?> and <(mouse y) < (130)>> then
pen down
else
pen up
end
end
when I receive [new colour v]
set pen color to (colour)
How to use this: Click the green flag. Click a ball to pick a colour, then hold the mouse button down on the stage and drag to draw.
3 · Ready to share
An app you made makes sense to you. A new user has never seen it. Three things help them:
- A line of help when it starts. Run it as its own green-flag script, so it does not hold up the pencil.
- A clear key, so nobody has to press the green flag to start again.
- Instructions, and Notes and Credits, written on the project page. Say which keys do what, and name anything you borrowed.
Basic — the finished Sketch Pad 25 min
Open your sketch pad from last lesson.
Step 1 — the Mirror
- Make the Mirror from the Learnt.
- Test it with the pencil tool: both halves should match.
Step 2 — the Mirror changes tools
- Give the Mirror key 1, 2 and 3 scripts that set its own pen size and colour, like the Pencil’s.
- In the Mirror’s loop, add the same
if <(tool) = [rainbow]> thenbefore pen down. - Test the eraser on both sides.
Step 3 — ready to share
- Add a second green-flag script to the Pencil:
say [Drag to draw. Keys 1, 2, 3 change the tool. C clears.] for (3) seconds. - Add
when [c v] key pressedwitherase all. - Click See Project Page. Write the Instructions and the Notes and Credits.
when flag clicked
say [Drag to draw. Keys 1, 2, 3 change the tool. C clears.] for (3) seconds
when [c v] key pressed
erase all
How to use this: Click the green flag, then click the stage once. Press 1, 2 or 3 for a tool, click a ball for a colour, hold the mouse button down and drag to draw, and press C to clear.
The help appears, but nothing draws for three seconds.
The say [Drag to draw] for (3) seconds is in the drawing script. Move it into a green-flag script of its own.
The mirror side stays blue when I use the rainbow.
The Mirror’s loop is missing the rainbow check from Step 2.
A mirror switch
- A variable called
mirror, shown on the Stage. It starts at 1. - Press M and it becomes 0: the Mirror hides and stops drawing.
- Press M again and it comes back.
How to use this: Click the green flag, then click the stage once. Hold the mouse button down and drag to draw, then press M and draw again.
Teacher reveal
when [m v] key pressed
set [mirror v] to ((1) - (mirror))
1 − 1 is 0 and 1 − 0 is 1, so one block flips it both ways. The Mirror’s loop wraps its drawing in if <(mirror) = [1]> then, with hide and pen up in the else.
Four ways
Add two more pencils, so one drag makes four lines.
- Mirror left and right, as now.
- Also mirror top and bottom of the paper.
- The paper runs from y: −180 to y: 130, so its middle is y: −25.
- No pencil ever draws inside the toolbar.
How to use this: Click the green flag, then hold the mouse button down on the stage and drag to draw.
Teacher reveal
Mirroring about y: −25 is ((-50) - (mouse y)): −25 take away the distance, and the distance is the mouse y + 25. A pencil at the bottom edge, y: −180, mirrors to y: 130 — the toolbar’s edge exactly, so nothing leaks in.
go to x: (mouse x) y: ((-50) - (mouse y))
A start card
A three-second message is easy to miss. Make the user read it first.
- On the green flag, the pencil shows how to use the app, and stays still.
- Nothing can be drawn yet.
- A click anywhere starts the app, and the message goes away.
How to use this: Click the green flag and read the message. Then click the stage once to start, and hold the mouse button down and drag to draw.
Teacher reveal
say [Sketch Pad! Drag to draw. Click a ball for a colour. Click to start.]
wait until <mouse down?>
wait until <not <mouse down?>>
say []
The two waits are one click: down, then up. With only the first, the click that starts the app also draws a dot.
A kaleidoscope
Eight pencils from one hand. Not eight sprites — one hidden sprite and seven clones.
- The pattern turns round the middle of the paper, (0, −25).
- Your Pencil is one of the eight. Seven clones are the rest.
- Each clone knows which of the seven it is, and works out its own place.
How to use this: Click the green flag, then hold the mouse button down on the stage and drag to draw. Click a ball to change the colour.
Teacher reveal
when flag clicked
hide
set [slot v] to (0)
repeat (7)
change [slot v] by (1)
create clone of [myself v]
end
when I start as a clone
forever
set [dx v] to (mouse x)
set [dy v] to ((mouse y) - (-25))
if <(slot) = [1]> then
go to x: ((0) - (dx)) y: ((-25) + (dy))
end
if <(slot) = [4]> then
go to x: (dy) y: ((-25) + (dx))
end
if <<mouse down?> and <(y position) < (130)>> then
pen down
else
pen up
end
end
Slots 2, 3, 5, 6 and 7 follow the same pattern with the other signs. A hidden clone still draws — the pen does not care whether the sprite is shown.
Summary 5 min
- The mirror of x is
((0) - (mouse x)). The y does not change. - A second pencil can draw from the same mouse, at a worked-out place.
- One broadcast reaches every sprite, so each pencil can change its own pen.
- An app is ready to share when a new user can use it from the screen alone.
- Mirror image
- The same shape, flipped, as if seen in a mirror.
- Symmetry
- When one half of a picture matches the other half.
- Instructions
- The box on the project page that tells a user what to do.
- Credits
- Naming the people and things your project borrowed from.
Hand in
Save your Sketch Pad — the arc is finished. Next lesson the pen stops following your hand and starts following rules: shapes drawn by the code itself.