Computer Science
Grade 8
20 min
Drawing Simple Shapes: Lines, Circles, and Squares
Learn how to draw simple shapes like lines, circles, and squares using digital tools. Practice creating basic drawings.
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Identify and describe the Cartesian coordinate system used in computer graphics.
Write code (or pseudo-code) to draw a straight line segment between two given points.
Write code (or pseudo-code) to draw a square or rectangle using its top-left corner, width, and height.
Write code (or pseudo-code) to draw a circle using its center coordinates and radius.
Combine basic shapes to create more complex visual compositions.
Explain the concept of pixels and how they form digital images.
Ever wondered how video games 🎮 or animated movies bring characters and worlds to life from just code?
In this lesson, you'll learn the fundamental building blocks of all computer graphics: drawing simple shapes like lines, circles, and squares. Understanding these basics...
2
Key Concepts & Vocabulary
TermDefinitionExample
Coordinate SystemA system that uses numbers (coordinates) to uniquely determine the position of a point in space, typically (x, y) for 2D graphics.In computer graphics, the top-left corner of the screen is often (0,0), with 'x' increasing to the right and 'y' increasing downwards.
PixelThe smallest individual unit of a digital image or display, a tiny dot of color. All shapes are ultimately made of pixels.A screen resolution of 1920x1080 means there are 1920 pixels horizontally and 1080 pixels vertically, making up the entire display.
Origin (0,0)The starting point of the coordinate system, typically the top-left corner of the drawing canvas or screen in computer graphics.If you draw a line from (0,0) to (100,0), it starts at the very top-left cor...
3
Core Syntax & Patterns
Drawing a Line
draw_line(start_x, start_y, end_x, end_y)
This function connects two points (start_x, start_y) and (end_x, end_y) with a straight line. Use it when you need to draw edges, boundaries, or simple strokes.
Drawing a Rectangle/Square
draw_rectangle(top_left_x, top_left_y, width, height)
This function draws a rectangle starting from its top-left corner (top_left_x, top_left_y) and extending by the specified width and height. For a square, simply set 'width' equal to 'height'.
Drawing a Circle
draw_circle(center_x, center_y, radius)
This function draws a circle centered at (center_x, center_y) with a given radius. The radius determines the size of the circle from its center to any point on its edge.
5 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
You need to draw a simple snowman. It consists of three circles stacked vertically, centered horizontally at x=200. The bottom circle is at y=300 with radius 60. The middle circle sits directly on top of the bottom one and has a radius of 40. The top circle (head) sits on the middle one and has a radius of 20. Which command draws the MIDDLE circle?
A.draw_circle(200, 220, 40)
B.draw_circle(200, 200, 40)
C.draw_circle(200, 260, 40)
D.draw_circle(200, 240, 40)
Challenging
A graphic on the screen shows a square with its top-left corner at (20, 30) and its bottom-right corner at (120, 130). Which single line of pseudo-code created this square?
A.draw_rectangle(20, 30, 120, 130)
B.draw_rectangle(20, 30, 100, 100)
C.draw_rectangle(70, 80, 100, 100)
D.draw_rectangle(20, 120, 30, 130)
Challenging
You have drawn a robot face using `draw_rectangle(50, 50, 100, 100)`. You now want to add a circular eye centered 25 pixels from the left edge and 30 pixels from the top edge *of the square*. What are the absolute canvas coordinates for the center of this eye?
A.(25, 30)
B.(125, 130)
C.(75, 80)
D.(50, 50)
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free