We will use the 5 pixel grid to trace out this image. The image of this is shown below:
- Lift up the pen
- Move the turtle to the position (0, -35)
- Set the pen size to 10 pixels
- Draw a circle of radius 80 pixels
- Lift up the pen
- Move the turtle to the position (0, -125)
- Place the pen down
- Draw a circle of radius 80 pixels
- Lift up the pen
- Move the turtle to the position (-25, -185)
- Set the heading to 90 degrees
- Place the pen down
- Move forward by 150 pixels
- Repeat steps 9 to 13 but change the position of step 10 to (25, -185)
- Lift up the pen
- Move the turtle to the position (-25, 185)
- Set the heading to 270 degrees
- Place the pen down
- Move forward by 150
- Repeat steps 15 to 19 but change the position of step 16 to (25, 185)
- Lift up the pen
- Move the turtle back to its home position
- Change its colour to white
- Set its heading to 270 degrees
- Change its pen size to 40
- Place the pen down
- Move backward by 40 pixels
- Move forward by 80 pixels
Using Turtle Graphics
We will use the template.py file and rename it to nyansapo.py.
The code for the first four steps is given below:
turtle.penup()
turtle.setposition(0, -35)
turtle.pensize(10)
turtle.pendown()
turtle.circle(80)
The generated image is shown below:
The code for steps 5 to 8 is given below:
turtle.penup()
turtle.setposition(0, -125)
turtle.pendown()
turtle.circle(80)
The generated image is given below:
The code for steps, 9 to 13 is given below:
turtle.penup()
turtle.setposition(-25, -185)
turtle.setheading(90)
turtle.pendown()
turtle.forward(150)
The code for step 14 is given below:
turtle.penup()
turtle.setposition(25, -185)
turtle.setheading(90)
turtle.pendown()
turtle.forward(150)
The generated image is shown below:
turtle.penup()
turtle.setposition(25, 185)
turtle.setheading(270)
turtle.pendown()
turtle.forward(150)
The code for step 20 is given below:
turtle.penup()
turtle.setposition(-25, 185)
turtle.setheading(270)
turtle.pendown()
turtle.forward(150)
The generated image is shown below:
The code for steps 21 to 28 is given below:
turtle.penup()
turtle.home()
turtle.color(“white”, “white”)
turtle.setheading(270)
turtle.pensize(40)
turtle.pendown()
turtle.backward(40)
turtle.forward(80)
The generated image is shown below:
Conclusion
We have succeeded in drawing the symbol Nyansapo. It wasn't so difficult to draw.
No comments:
Post a Comment