Eyes on Me 123 · Year 7–8 Digital Technology · Student Edition
Draw with JavaScript
Khan Academy Drawing Basics & Colours · Three lessons
Lesson 1 / Drawing basics
Draw with coordinates
Position, size and drawing order
Learning intention
Use x and y coordinates and shape commands to build a picture.
Success criteria
I can predict where a rectangle or ellipse will appear.
I can use at least three kinds of shape commands.
I can explain what changed when I moved a command.
Do Now · 5 minutes
On a 400 × 400 canvas, which is closer to the bottom: (60, 90) or (60, 300)?
Which number changes to move a shape right without moving it down?
Predict where the top-left corner of rect(40, 80, 120, 60) will be.
Code lab
Move a rectangle
Predict what the x slider will change. Test it. Then move the rectangle by changing y. Turn on the grid to check its top-left corner.
Code reference
Open a command to see what each part does.
rect(x, y, w, h)
Draws from its top-left corner. The last two numbers are width and height.
rect(40, 80, 120, 60);
ellipse(x, y, w, h)
Draws around its centre. Equal width and height make a circle.
ellipse(290, 130, 80, 80);
line(x1, y1, x2, y2)
Joins two points. Give the x and y of each end.
line(60, 260, 340, 260);
triangle(x1, y1, x2, y2, x3, y3)
Joins three corner points in order.
triangle(130, 330, 200, 270, 270, 330);
// comment
JavaScript skips text after // on that line. Use it to explain part of a picture.
// Draw the main shape
Try a worked example
Swap the first rectangle and the door line. Run it. What happened to the door, and why?
Predict first, then change the example and run it. Use the result to explain what the code did.
Choose a project
Choose one level. Meet all three requirements and test a change before you export.
Starter
Robot ID card
Design a friendly robot that would fit on an ID card.
Draw a rectangular head and body, two matching ellipse eyes and a line mouth.
Use at least two more shapes for arms, buttons or an antenna. Keep the drawing inside the canvas.
Move the face feature you noticed first. Run both versions and describe the visible change.
Show a hint
Place one eye, then keep its y and size when you make the other eye.
Core
Reporoa bus stop
Draw a roadside scene with a shelter, a road and a bus.
Use a rectangle for the shelter and a triangle for its roof. Add a post and a sign.
Build a bus from a body, three windows and two ellipse wheels. Put the windows after the body so they show.
Add road markings using lines. Use 12 or more drawing commands and check that the bus looks grounded.
Show a hint
Keep the two wheels at the same y, then use the grid to align the windows.
Advanced
Mini skatepark plan
Make a readable top-down layout with different zones.
Include a ramp, bowl, rails, entry and seating using at least 16 drawing commands and all four shape types.
Use the 200-pixel centreline to align a mirrored pair of features. Add a foreground detail that overlaps a larger shape on purpose.
Write three comments marking the zones. Test swapping the draw order of an overlap and explain why you chose your final order.
Show a hint
For matching features, try centres at x = 100 and x = 300 with the same y value.
Code editor
400 × 400 canvas. The top left is (0, 0). The grid is a guide and stays out of exported images. Commands in this reference run here, including simple JavaScript loops.
Preview
Drafts autosave in this browser when available. Download a copy before changing devices. Use Ctrl/⌘ + Enter to run from the editor.
Exit ticket
Explain where ellipse(100, 240, 40, 60) is centred, then describe one change you tested.
For submission, turn in your code file, preview image and response file where your teacher has set the assignment.
Lesson 2 / Coloring
Mix colours with RGB
Background, fill and outlines
Learning intention
Use RGB values and drawing styles to make parts of a picture stand out.
Success criteria
I can explain what each number in RGB controls.
I can set the background, fill and outline separately.
I can predict which later shapes will share a colour or outline.
Do Now · 5 minutes
What does the 80 mean in rect(20, 30, 80, 50)?
Which channel is strongest in (230, 45, 60)?
What could happen if background() comes after the shapes you want to show?
Code lab
Mix a colour
Set red to 255 and green and blue to 0. Predict what will happen when green is increased. Why do both shapes change together?
Code reference
Open a command to see what each part does.
background(r, g, b)
Paints the whole canvas. Put it first when you want a backdrop.
background(223, 240, 252);
fill(r, g, b)
Sets the inside colour for shapes drawn after this line, until you change it.
fill(250, 170, 45);
stroke(r, g, b)
Sets the outline and line colour. It also turns outlines back on after noStroke().
stroke(30, 65, 62);
strokeWeight(n)
Sets the thickness of later outlines and lines in pixels.
strokeWeight(4);
noStroke()
Turns outlines off and hides any later line() until stroke() is called again.
noStroke();
Try a worked example
Change just the green value in the mountain fill. Which shapes changed? Then add a separate fill before the second mountain.
Predict first, then change the example and run it. Use the result to explain what the code did.
Choose a project
Choose one level. Meet all three requirements and test a change before you export.
Starter
Colour a lunchbox
Create a lunchbox with three foods and a drink.
Draw the lunchbox and four items using rectangles, ellipses and at least one triangle.
Choose a background and use at least four distinct RGB fills. Add an outline to one item and leave a different item without one.
Change just one RGB channel on one food. Describe which colour changed and what it looks like now.
Show a hint
Start with the box, then draw the food on top of it. Group each item’s fill and shapes together.
Core
Lake at golden hour
Build a layered scene using sky, land and water.
Place a sun, two hills, a shoreline and a lake. Use at least 12 drawing commands.
Mix five distinct RGB fills, including two related colours in the water or hills. Give one feature a thick outline and leave another without one.
Add reflections using at least three lines. Then test two different stroke weights and decide which reads best.
Show a hint
Put big background shapes first. If the lake lines disappear, turn the stroke on before drawing them.
Advanced
Day-to-night street
Design a two-panel picture of one place at different times.
Split the canvas into two 200-pixel panels. Repeat the same three identifiable objects in both panels, shifted 200 pixels across.
Build a daylight palette and a night palette with at least four colours each. Include warm lighting at night and one silhouette.
Use at least two stroke weights and a deliberate noStroke() section. Describe two colour choices that keep the scene readable.
Show a hint
Make the two skies with filled rectangles. Using background() again would cover both panels.
Code editor
400 × 400 canvas. The top left is (0, 0). The grid is a guide and stays out of exported images. Commands in this reference run here, including simple JavaScript loops.
Preview
Drafts autosave in this browser when available. Download a copy before changing devices. Use Ctrl/⌘ + Enter to run from the editor.
Exit ticket
Give an RGB value for pure blue. Explain where you would place a fill() line to recolour just the second of two shapes.
For submission, turn in your code file, preview image and response file where your teacher has set the assignment.
Lesson 3 / Drawing basics + Coloring
Design a finished scene
Composition, testing and refinement
Learning intention
Combine shapes, colour and layering to communicate a clear idea.
Success criteria
I can organise a picture into a background, main subject and foreground.
I can use contrast and size to show where to look first.
I can test a change and explain why I kept or revised it.
Do Now · 5 minutes
Which shape should be drawn first, the sky or the tree in front of it? Why?
If a pale yellow sign blends into a pale sky, what colour change would help?
Spot the problem in ellipse(200, 120, 50, 50; and rewrite it.
Code lab
Make the sign stand out
Make a low-contrast sign, then try a darker fill or thicker outline. Which change made its shape easier to see?
Code reference
Open a command to see what each part does.
background() → shapes → details
Code runs from top to bottom. Draw the backdrop first and nearest details last.
Use comments to find and edit related commands. State what each section draws.
// 1. Background
// 2. Main subject
// 3. Foreground
for (var i = 0; i < 5; i++)
Optional advanced technique. This repeats five times with i from 0 to 4. The multiplication spaces the shapes 36 pixels apart.
for (var i = 0; i < 5; i++) {
ellipse(70 + i * 36, 325, 14, 14);
}
Try a worked example
Try a sign fill close to the sky colour. Then restore the gold and ask a partner which element their eye finds first.
Predict first, then change the example and run it. Use the result to explain what the code did.
Choose a project
Choose one level. Meet all three requirements and test a change before you export.
Starter
Trail sign illustration
Create a visitor sign for a walking track with a symbol a visitor can read from far away.
Use three layers and at least 10 drawing commands. Add an arrow, tree or walking-track symbol using two shape types.
Use at least four fills and a visible outline around the sign or symbol.
Ask a partner what they see first. Change one colour, size or position and explain whether the change helped the symbol stand out.
Show a hint
Build the sign board before its symbol. Use lines with a visible stroke for an arrow.
Core
Retro market promo
Design an illustration for a market stall that makes one product easy to spot.
Draw a setting, stall and foreground display using at least 15 shapes or lines. Add a roof or awning and three products.
Make one product the focal point through size and contrast. Use at least five fills plus two outline styles.
Write comments for the layers. Ask a partner to identify the product, then make two edits based on the feedback and describe their effects.
Show a hint
Use the biggest or brightest shape for the product you want shoppers to spot first.
Advanced
Local festival poster
Build a poster illustration with a main stage and patterns that guide the eye toward it.
Make three clear layers. Add a main stage, foreground crowd or path, and at least two background features.
Use all four shape commands and at least six RGB fills. Create a repeated feature of five or more elements, using a loop if you’re ready.
Test two layout or palette choices against a partner’s feedback. Explain the changes and how the repeated feature supports the focal point.
Show a hint
The reference loop spaces items apart. Change the starting x and spacing to match your stage or path.
Code editor
400 × 400 canvas. The top left is (0, 0). The grid is a guide and stays out of exported images. Commands in this reference run here, including simple JavaScript loops.
Preview
Drafts autosave in this browser when available. Download a copy before changing devices. Use Ctrl/⌘ + Enter to run from the editor.
Exit ticket
Point to two commands that support your focal point. Record one change you tested and why you kept or revised it.
For submission, turn in your code file, preview image and response file where your teacher has set the assignment.