Draw with shapes
Meet the circle, rectangle, ellipse, line and polygon, then stack them into a little house. A first SVG project with live examples you can change.
Ages 7 to 10, about 20 minutes. You will practice: How the SVG canvas and its numbers work, How to draw circles, rectangles, ellipses, lines and polygons, The difference between fill and stroke, Why the order of shapes matters.
Goal: draw a small house using only simple shapes.
Every picture on this page is SVG, which is a way of drawing with words and numbers. If you want to know more, read What is SVG?. You do not need to read it first. Each example below is live, so you can change the code and see the picture change.
Step 1: Start with a circle
An SVG picture sits on a canvas. The viewBox tells the canvas how big it is. Here it is 200 units wide and 200 units tall. The point 0,0 is the top left corner.
A circle needs three numbers. cx is how far across the center is. cy is how far down the center is. r is the radius, which is the distance from the center to the edge.
Try this: change r to 30 to make the circle smaller. Then change cx to 50 to slide it to the left.
Step 2: Add a rectangle
A rectangle uses x and y for its top left corner. Then width and height say how big it is. Remember that y gets bigger as you go down, not up.
Try this: make the grass wider by changing width to 180 and x to 10. Can you make a tall, thin rectangle instead?
Step 3: Ellipses and lines
An ellipse is a squashed circle. It has two radii: rx across and ry up and down. A line goes from one point to another. It needs x1 and y1 for the start, and x2 and y2 for the end. A line also needs a stroke, which is its color. You will meet stroke properly in the next step.
Try this: change rx to 50 to make a fat balloon. Then make the string slant by changing the last x2 to 130.
Step 4: Fill and stroke
fill is the color inside a shape. stroke is the color of its outline. stroke-width is how thick the outline is. You can set fill="none" to leave the inside empty.
Try this: give the circle a fill of lightpink. Then make the square’s outline 12 wide.
Step 5: Polygons
A polygon is a shape with straight sides. You give it a list of points. Each point is two numbers, across then down. The shape joins the points in order and closes itself at the end. Three points make a triangle.
Try this: add a fourth point, such as 100,170, to the end of the list. What shape do you get?
Step 6: Stack shapes into a house
SVG draws shapes in the order you write them. The first shape is at the back and the last shape is at the front. That is why the wall comes before the door and window here. If the door came first, the wall would cover it.
Try this: move the line that draws the door so it comes before the line that draws the house wall. The door disappears behind the wall. Move it back, then add a second window on the right side of the house.
For teachers and families
Ask: “Which shapes did you use for each part of the house, and could you build the same part with different shapes?” As a classroom extension, have children plan a picture on squared paper first, writing down the numbers for each shape, then type them in. Counting squares is a gentle way to meet coordinates. Next, try Color a robot.
Next project: Color a robot