We will use the 5 pixel grid to trace out this image. The image of this is shown below:
The width of the blocks is taken to be 4 squares. With this information, we can draw the entire shape. We will draw the horizontal lines first.
The plan to draw this shape is given below:
- Lift the turtle
- Set the pen size to 40 pixels
- Move the turtle to the position that is (-160. -170)
- Place the pen down
- Move the turtle forward by 320 pixels
- Lift up the pen
- Move the turtle to the position that is (-120. 170)
- Place the pen down
- Move the turtle forward by 240 pixels
- Lift up the pen
- Move the pen to the point that is (-170. -80)
- Set the heading of the pen to 90 degrees
- Place the pen down
- Move 130 pixels forward
- Set the heading of the pen to 0 degrees
- Move the turtle forward by 340 pixels
- Set the heading of the pen to 270 degrees
- Move 130 pixels forward
- Lift up the pen
- Move the pen to the position (-80, -170)
- Set the heading of the turtle to 90 degrees
- Place the pen down
- Move forward by 200 pixels
- Lift up the pen
- Move the pen to the position (-80, 0)
- Set the heading of the turtle to 90 degrees
- Place the pen down
- Move forward by 250 pixels
- Lift up the pen
- Move the pen to the position (80, -170)
- Set the heading of the turtle to 90 degrees
- Place the pen down
- Move forward by 200 pixels
Using Turtle Graphics
We will use the template.py file and rename it to hwemudua.py.
The code for steps 1 to 5 is shown below:
turtle.penup()
turtle.pensize(40)
turtle.setposition(-160, -170)
turtle.pendown()
turtle.forward(320)
The generated image is shown below:
turtle.penup()
turtle.setposition(-160, 170)
turtle.pendown()
turtle.forward(240)
The generated image is shown below:
The steps 10 to 18 are given in code as shown below:
turtle.penup()
turtle.setposition(-170, -80)
turtle.setheading(90)
turtle.pendown()
turtle.forward(130)
turtle.setheading(0)
turtle.forward(340)
turtle.setheading(270)
turtle.forward(130)
The generated image is shown below:
The steps 19 to 23 are given in code shown below:
turtle.penup()
turtle.setposition(-80, -170)
turtle.setheading(90)
turtle.pendown()
turtle.forward(200)
The generated image is shown below:
turtle.penup()
turtle.setposition(0, -80)
turtle.setheading(90)
turtle.pendown()
turtle.forward(250)
The generated image is shown below:
turtle.penup()
turtle.setposition(80, -170)
turtle.setheading(90)
turtle.pendown()
turtle.forward(200)
The generated image is shown below:
At the end of this section, we have successfully used Python turtle to draw the Hwemudua symbol.
This is one of the easiest symbol to draw because it is made up of lines.
No comments:
Post a Comment