We will use the 5 pixel grid to trace out this image. The image of this is shown below:

- Lift up the pen
- Set the pensize to 40 pixels
- Draw the upper prong
- Draw the lower prong
- Draw the upper arrow
- Draw the lower arrow
- Draw the middle hexagon

Using Turtle Graphics

We will use the template.py file and rename it to nteasee.py.

The code for the first two steps are shown below:

turtle.penup()

turtle.pensize(40)

To draw the upper prong, we must move the pen to the position (-70, 180). We do this because the pensize is 40 pixels and will take up a space of 20 pixels when it is placed down.

We place the pendown and move forward by 130 pixels, turn left by 90 degrees, move forward by 140 pixels, turn left by 90 degrees and move forward by 130 pixels.

The code to do this is shown below:

turtle.setheading(270)

turtle.setposition(-70, 180)

turtle.pendown()

turtle.forward(130)

turtle.left(90)

turtle.forward(140)

turtle.left(90)

turtle.forward(130)

The generated image is shown below:

To draw the lower prong, we need to use the steps above but modify them for our purposes.

To do this, we move the pen to the position (-70, -180) and we set the heading of the turtle to 90 degrees.

Next we move up by 130 pixels, turn right by 90 degrees, move forward by 140 pixels, turn right by 90 degrees and move down by 130 pixels.

The code to do this is shown below:

turtle.penup()

turtle.setheading(90)

turtle.setposition(-70, -180)

turtle.pendown()

turtle.forward(130)

turtle.right(90)

turtle.forward(140)

turtle.right(90)

turtle.forward(130)

The generated image is shown below:

Drawing the upper arrow is easy. We need to use a filled shape to do this. To start we, we move the turtle to the left position of the arrow.

We must reduce the pensize of the turtle to 1. Next move forward by 60 pixels then turn left by 90 degrees and move forward by 15 pixels.

We need to find the angle between the current position of the turtle and its next position as well as the distance between them.

Once we have done the above, the rest is easy. All we need to do is reverse the steps and draw the other half of the arrow.

The code to lift up the pen and set its pensize to 1 is shown below:

turtle.penup()

turtle.pensize(1)

We move the position of the pen to the left side of the arrow as well as change its heading. The code to do this shown below:

turtle.setposition(-20, 70)

turtle.setheading(90)

turtle.pendown()

We move forward by 60 pixels, turn left by 90 degrees and move forward by 15 pixels. The code to do this is shown below:

turtle.begin_fill()

turtle.forward(60)

turtle.left(90)

turtle.forward(15)

The current position of the turtle is at (-35, 130). Its next position is (0, 190). To get there, we need to find the angle between the two points. The code to do this is shown below:

myradians = math.atan2(190 - 130, 0 - (-35))

angle = math.degrees(myradians)

To find the length between the two points, we use the coordinateDistance function. The code for it is shown below:

def coordinateDistance(x1, y1, x2, y2):

dx = x1 - x2

dy = y1 - y2

D = math.sqrt((dx * dx) + (dy * dy))

return D

We call the function using the code shown below:

length = coordinateDistance(-35, 130, 0, 190)

The code to draw the rest of the arrow is given below:

turtle.setheading(angle)

turtle.forward(length)

turtle.setheading(360 - angle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(15)

turtle.setheading(270)

turtle.forward(60)

turtle.end_fill()

The generated image is shown below:

To draw the lower part, we need to move the turtle to the position () and reverse the steps above.

The code to do this is shown below:

turtle.penup()

turtle.setposition(-20, -70)

turtle.setheading(270)

turtle.pendown()

turtle.begin_fill()

turtle.forward(60)

turtle.right(90)

turtle.forward(15)

turtle.setheading(360-angle)

turtle.forward(length)

turtle.setheading(angle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(15)

turtle.setheading(90)

turtle.forward(60)

turtle.end_fill()

The generated image is shown below:

To complete this symbol we need to draw the hexagon.

To do so, we need to move the turtle to the left side of the hexagon. The coordinate of this position is (-20, -30).

The next thing is to find the angle and length between this position and the next position. The coordinates of the next position are (-35, 0).

The code to find the angle and length is given below:

myradians = math.atan2(0 - (-30), -35 - (-20))

hexAngle = math.degrees(myradians)

hexLength = coordinateDistance(-20, -30, -35, 0)

The code to draw the hexagon is given below:

turtle.penup()

turtle.setposition(-20, -30)

turtle.setheading(hexAngle)

turtle.pendown()

turtle.begin_fill()

turtle.forward(hexLength)

turtle.setheading(180 - hexAngle)

turtle.forward(hexLength)

turtle.setheading(0)

turtle.forward(40)

turtle.setheading(360 - (180 - hexAngle))

turtle.forward(hexLength)

turtle.setheading(360 - hexAngle)

turtle.forward(hexLength)

turtle.setheading(180)

turtle.forward(40)

turtle.end_fill()

The generated image is shown below:

Conclusion

At the end of this section, we have successfully drawn the Nteasee symbol.

This post is part of the series: Drawing Adinkra Symbols using Python. The goal is to draw 40 Adinkra symbols using the Python programming language.

## No comments:

## Post a Comment