We will use the 5 pixel grid to trace out this image. The image of this is shown below:
The plan to draw the shape is shown below:
- Lift up the pen
- Set the pen size to 30
- Draw the vertical center lines
- Set the pen size to 20
- Draw the 3 horizontal center lines
- Draw all the vertical lines
- Draw all the horizontal lines
Using Turtle Graphics
We will use the template.py file and rename it to neaonnim.py.
The code for steps 1 and 2 are given below:
turtle.penup()
turtle.pensize(40)
To draw the first vertical line, we need to move the pen to the position (0, 50), set the heading of the turtle to 90 degrees, place the pen down and move it to the position (0, 160) by moving forward by 110 pixels. The code to do this is shown below:
turtle.setposition(0, 50)
turtle.setheading(90)
turtle.pendown()
turtle.forward(110)
The generated image is shown below:
turtle.penup()
turtle.setposition(0, -50)
turtle.setheading(270)
turtle.pendown()
turtle.forward(110)
The generated image is shown below:
turtle.pensize(20)
To draw the three horizontal center lines, We need to move the mouse to the positions of the shape and move forward by 140 pixels. The position of the lines are at (-70, 40), (-70, 0) and (-70, -40). The code that does this is shown below:
turtle.penup()
turtle.setposition(-70, 40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)
turtle.penup()
turtle.setposition(-70, 0)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)
turtle.penup()
turtle.setposition(-70, -40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)
The generated image is shown below:
The first two lines have the same length while the third line is the longest. The fourth line is the same length as the third line while the last 2 lines have the same length as the first two.
To draw these vertical lines, we need to lift the pen up and set its heading to 270 degrees. Then we can start drawing the vertical lines. The code to do this is shown below:
turtle.penup()
turtle.setheading(270)
turtle.setposition(-170, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(-120, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(-70, 180)
turtle.pendown()
turtle.forward(360)
turtle.penup()
turtle.setposition(170, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(120, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(70, 180)
turtle.pendown()
turtle.forward(360)
The generated image is shown below:
The horizontal lines on the left are going to be drawn from the first to the last. The first and the last are longer than the others.
To draw the horizontal lines, we have to move the turtle and set its heading to 180 degrees. From there, we draw to the left of the shape. We draw the lines along the longest line. The code to do this is shown below:
turtle.penup()
turtle.setheading(180)
turtle.setposition(-70, 180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setposition(-70, 130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, 80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setheading(0)
turtle.setposition(70, 180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setposition(70, 130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, 80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -180)
turtle.pendown()
turtle.forward(110)
The generated image is shown below:
Conclusion
At the end of this section, we have successfully drawn the Nea Onnim No Sua A Ohu. It is easy to draw but requires a strategy before you start drawing.
Have a great weekend.
No comments:
Post a Comment