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

The plan to draw this shape is given below:

- Get the coordinates of the starting points of the stars
- Lift up the pen
- Set the pen size to 10 pixels
- Move it to the starting point of the first star
- Place the pen down
- Move forward by the y coordinate of the star
- Find the angle between the turtle and the topmost part of the star
- Set the heading of the pen to angle
- Find the distance between the turtle and the topmost part of the star
- Move forward by the distance found
- Set the heading of the pen to the value of the 360 minus the angle
- Move forward by the distance found
- Set the heading of the pen to 0 degrees
- Move forward by the y coordinate of the star
- Find the angle between the turtle and the next position of the line
- Find the distance between the turtle and the line
- Set the heading of the pen to angle obtained in 15
- Move forward by distance obtained in 16
- Set the heading of the pen to value of 180 minus the value obtained in 15
- Move forward by the distance obtained in 16
- Set the heading of the pen to 180
- Move forward by the y coordinate of the star
- Set the heading of the pen to value of the angle obtained in 7 minus 180 degrees
- Move forward by the distance obtained in 9
- Set the heading of the pen to the value of 180 minus the angle obtained in 7
- Move forward by the distance obtained in 9
- Set the heading of the pen to 180 degrees
- Move forward by the y coordinate of the first star
- Set the heading of the pen to 300 minus the value obtained in 15
- Move forward by the value obtained in 16
- Set the heading of the pen to 360 minus the value obtained in 15
- Move forward by the value obtained in 16
- Repeat steps 4 to 32 for the second star
- Repeat steps 4 to 32 for the third star

__Using Turtle Graphics__

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

The first step of our plan is manual. We need to find the coordinates of the starting points of the stars.

Starting from the smallest, these are: (-50, 40), (-100, 70) and (-150, 100). The shape we used is slightly off by 10 pixels.

One of the rules of design for Adinkra symbols is symmetry. As a result of this, we will shift the starting points down by 10 pixels.

The new coordinates are now: (-50, 30), (-100, 60) and (-150, 90). Visual inspection of the new coordinates reveal a pattern.

The code for steps 2 to 6 is given below:

turtle.penup()

turtle.setposition(-50, 30)

turtle.pensize(10)

turtle.pendown()

turtle.forward(30)

Next we try to find the angle from the current position of the turtle to the topmost position of the star. The coordinates of the two positions are (-20, 30) and (0, 60). The code to do this is shown below:

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

upperAngle = math.degrees(myradians)

turtle.setheading(upperAngle)

Next we find the distance between the two points using the coordinateDistance function shown below:

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

dx = x1 - x2

dy = y1 - y2

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

return D

length = coordinateDistance(-20, 30, 0, 60)

turtle.forward(length)

Steps 11 and 12 are easy as we have the values we need the code for these steps is shown below:

turtle.setheading(360 - upperAngle)

turtle.forward(length)

The code for steps 13 and 14 is given below:

turtle.setheading(0)

turtle.forward(30)

The code for step 15 to 18 is shown below:

myradians = math.atan2(0 - 30, 30 - 50)

lowerAngle = math.degrees(myradians)

turtle.setheading(lowerAngle)

lowerLength = coordinateDistance(50, 30, 30, 0)

turtle.forward(lowerLength)

The code for steps 19 and 20 is given below:

turtle.setheading(180 - lowerAngle)

turtle.forward(lowerLength)

From this point on, the rest is easy as we have all the values we need.

The code for steps 21 and 22 is given below:

turtle.setheading(180)

turtle.forward(30)

The code for steps 23 and 24 is given below:

turtle.setheading(upperAngle - 180)

turtle.forward(length)

The code for steps 25 and 26 is given below:

turtle.setheading(180 - upperAngle)

turtle.forward(length)

The code for steps 27 and 28 is given below:

turtle.setheading(180)

turtle.forward(30)

The code for steps 29 and 30 is given below:

turtle.setheading(300 - lowerAngle)

turtle.forward(lowerLength)

The code for steps 31 and 32 is given below:

turtle.setheading(360 - lowerAngle)

turtle.forward(lowerLength)

The generated image is shown below:

We repeat the code starting from step 2. We will skip the steps in the code where the value is known. The code for steps 2 to 6 is shown below:

turtle.penup()

turtle.setheading(0)

turtle.setposition(-100, 60)

turtle.pendown()

turtle.forward(60)

Next we find the distance from the current position of the turtle to the position of the topmost part of the star. We know the coordinate of the turtle to be (-40, 60) and that of the topmost part to be (0, 120).

The code to draw the line is shown below:

turtle.setheading(upperAngle)

length = coordinateDistance(-40, 60, 0, 120)

turtle.forward(length)

The rest is easy from this point on. The code to draw the rest of the shape is shown below:

turtle.setheading(360 - upperAngle)

turtle.forward(length)

turtle.setheading(0)

turtle.forward(60)

turtle.setheading(lowerAngle)

turtle.forward(length)

turtle.setheading(180 - lowerAngle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(60)

turtle.setheading(upperAngle - 180)

turtle.forward(length)

turtle.setheading(180 - upperAngle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(60)

turtle.setheading(300 - lowerAngle)

turtle.forward(length)

turtle.setheading(360 - lowerAngle)

turtle.forward(length)

The generated image is shown below:

The code to do this is shown below:

turtle.penup()

turtle.setheading(0)

turtle.setposition(-150, 90)

turtle.pendown()

turtle.forward(90)

turtle.setheading(upperAngle)

length = coordinateDistance(-60, 90, 0, 180)

turtle.forward(length)

turtle.setheading(360 - upperAngle)

turtle.forward(length)

turtle.setheading(0)

turtle.forward(90)

turtle.setheading(lowerAngle)

turtle.forward(length)

turtle.setheading(180 - lowerAngle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(90)

turtle.setheading(upperAngle - 180)

turtle.forward(length)

turtle.setheading(180 - upperAngle)

turtle.forward(length)

turtle.setheading(180)

turtle.forward(90)

turtle.setheading(300 - lowerAngle)

turtle.forward(length)

turtle.setheading(360 - lowerAngle)

turtle.forward(length)

The generated image is shown below:

__Conclusion__

At the end of this section, we have successfully drawn the shape but there is a variance on the left side.

I shall address this when I review this section.

In this section we cover how to draw the Menso Wo Kenten symbol. It is basically a star shaped 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