Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Latest commit

 

History

History
35 lines (22 loc) · 2.17 KB

File metadata and controls

35 lines (22 loc) · 2.17 KB

Lab 1.3: Squares and Triangles and Stars, Oh, My!

In this lab, you will write your first SNAP programs to draw some simple shapes on the stage.

1. Drawing a square

1.1) Write a SNAP script that draws a square when the number 1 is pressed on the keyboard. Remember that each corner of a square is a 90° angle, as shown in the figure below.

square diagram

1.2) Add code so that the sprite says the word "square" while it is drawing. The sprite should stop saying "square" once it has finished drawing the square.

1.3) Add code so that pressing the space bar clears the pen marks from the stage.

2. Adding more shapes

2.1) Now that you've drawn a square, add code to draw the shapes in the following table. Each shape should be drawn when the number next to it is pressed on the keyboard. (For example, pressing 3 on the keyboard should draw a diamond.)

When this key is pressed... Draw a ...
1 Square
2 Equilateral triangle
3 Diamond
4 Pentagon
5 Parallelogram ("leaning rectangle")
6 (optional) 5-pointed star

You may want to draw a diagram similar to the one above of a square to figure out the angles in each shape.

2.2) Add code so that as each shape is being drawn, the sprite is saying the name of shape. The sprite should stop saying the name of the sprite when it is finished drawing.

2.3) Modify your code so that each different shape is drawn in a different color and with a different line thickness. So, for example, if the square is drawn in blue with a line thickness of 3, each other shape must be drawn in a color that is not blue and with a line thickness that is not 3.

2.4) Add code so that the sprite is hidden when it is not drawing. This is will make sure that the sprite is not obstructing the view of your beautiful artwork!