Saturday 28 April 2018

Nteasee


Nteasee means "understanding". It is the symbol of understanding and cooperation.

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:

  1. Lift up the pen
  2. Set the pensize to 40 pixels
  3. Draw the upper prong
  4. Draw the lower prong
  5. Draw the upper arrow
  6. Draw the lower arrow
  7. 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.

Wednesday 25 April 2018

Nsoromma


Nsoromma means "child of the heavens". It is the symbol of guardianship. A reminder that God is the father and watches over all people.

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:
  1. Lift up the pen
  2. Find the angle between the edge of the shape in the lower left quadrant and the top of the shape
  3. Find the distance between the edge of the shape in the lower left quadrant and the top of the shape
  4. Move the pen to the position of the lower left quadrant
  5. Set its heading to the value found in 2
  6. Move forward by the distance found in 3
  7. Continue alternating through steps 5 and 6 until the shape is completed
  8. Fill up the final shape
  9. Move to the rightmost position for the radius of the circle
  10. Draw a filled circle

Using Turtle Graphics

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

Step 1 is easy, we only need to lift up the pen. The code to do this is shown below:

turtle.penup()

For step 2 we need to find the angle between the lower left point of the symbol and its uppermost part. Their respective coordinates are (-140, -140) and (0, 195).

The code to do this is shown below:

turtle.penup()
myradians = math.atan2(195 - (-140), 0 - (-140))
angle = math.degrees(myradians)

The value of the angle will be used in drawing the entire shape.

Next we find the length between the two points using 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(-140, -140, 0, 195)

Steps 4 to 6 are easy enough. But we must use the fill property to draw the shape.

The code for the entire drawing is shown below:

turtle.setposition(-140, -140)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(angle)
turtle.forward(length)
turtle.setheading(360 - angle)
turtle.forward(length)
turtle.setheading(90 + angle)
turtle.forward(length)
turtle.setheading(90 - angle)
turtle.forward(length)
turtle.setheading(180 + angle)
turtle.forward(length)
turtle.setheading(180 - angle)
turtle.forward(length)
turtle.setheading(270 + angle)
turtle.forward(length)
turtle.setheading(270 - angle)
turtle.forward(length)
turtle.end_fill()

To really understand what is going on, add each setheading and forward combination gradually.

The generated image is shown below:



Drawing the circle is easy. We simply move the turtle to the position (50, 0), set its heading to 90 degrees and draw a filled circle.

The code to do this is shown below:

turtle.setposition(50, 0)
turtle.setheading(90)
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()

The generated image is shown below:


The only code that might appear strange is this line:

turtle.color("white", "white")

The above line makes the pencolor and fillcolor of the turtle white.

Conclusion

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

This is my favourite symbol in this series. It has an emergent property. It is made up of triangular shapes that combine to form it.

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.

Thursday 19 April 2018

Nnampo Pa Baanu


Nnampo Pa Baanu means "two good friends". It is the symbol of friendship.

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:
  1. Lift up the pen
  2. Set the pensize to 40 pixels
  3. Move the pen to the bottom of the  location of the center vertical
  4. Draw the center vertical
  5. Set the pensize to 30 pixels
  6. Draw the remaining center verticals
  7. Complete the outline of the shape
  8. Draw the semicircles
Using Turtle Graphics

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

The code for steps 1 and 2 is given below:

turtle.penup()
turtle.pensize(40)

The coordinates for the bottom of the center vertical are (0, -80). The length of the line is 160 pixels.

The code to draw this line is shown below:

turtle.setposition(0, -60)
turtle.pendown()
turtle.setheading(90)
turtle.forward(120)

The generated image is shown below:


To draw the remaining center verticals, we must first know their coordinates they are: (-165, 60), (-85, 60), (85, 60) and (165, 60).

The code to draw them is given below:

turtle.pensize(30)

turtle.penup()
turtle.setposition(-165, -60)
turtle.pendown()
turtle.setheading(90)
turtle.forward(120)

turtle.penup()
turtle.setposition(-85, -60)
turtle.pendown()
turtle.setheading(90)
turtle.forward(120)

turtle.penup()
turtle.setposition(85, -60)
turtle.pendown()
turtle.setheading(90)
turtle.forward(120)

turtle.penup()
turtle.setposition(165, -60)
turtle.pendown()
turtle.setheading(90)
turtle.forward(120)

The generated image is shown below:


To complete the outline of the shape, we need to draw the top horizontal line and the bottom horizontal line.

The coordinate for the upper line is (-165, 75) and its length is 330 pixels. The code to draw it is shown below:

turtle.penup()
turtle.setposition(-165, 75)
turtle.pendown()
turtle.setheading(0)
turtle.forward(330)

The coordinate for the lower line is (-165, -75). The code to draw it is shown below:

turtle.penup()
turtle.setposition(-165, -75)
turtle.pendown()
turtle.setheading(0)
turtle.forward(330)

The generated image is shown below:


Drawing the semicircles is easy. We need to move the turtle to the position of the rightmost sides and draw the circle.

The code to do this is shown below:

turtle.penup()
turtle.setposition(165, 75)
turtle.pendown()
turtle.setheading(90)
turtle.circle(80, 180)

turtle.penup()
turtle.setposition(-5, 75)
turtle.pendown()
turtle.setheading(90)
turtle.circle(80, 180)

The generated image is shown below:


To draw the lower semicircle we just invert the positions. The code to do this is shown below:

turtle.penup()
turtle.setposition(-165, -75)
turtle.pendown()
turtle.setheading(270)
turtle.circle(80, 180)

turtle.penup()
turtle.setposition(5, -75)
turtle.pendown()
turtle.setheading(270)
turtle.circle(80, 180)

The generated image is shown below:


Conclusion

At the end of this section we have succeeded in drawing the Nnampo Pa Baanu 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.

Mrammuo


Mrammuo means "crossing paths". It is the symbol of life challenges.

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:
  1. Lift up the pen
  2. Set the pensize to 15 pixels
  3. Draw the outer box
  4. Draw the inner diagonals
  5. Draw the serrated edges

Using Turtle Graphics

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

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

turtle.penup()
turtle.pensize(15)

The upper left coordinate for the outer box is (-175, 105). Its length is 350. The code to draw this line is given below:

turtle.setposition(-175, 105)
turtle.pendown()
turtle.forward(350)

We do the same for the lower part of the outer box. The code to do this is shown below:

turtle.penup()
turtle.setposition(-175, -105)
turtle.pendown()
turtle.forward(350)

The generated image is shown below:


To complete the box, we have to draw the vertical lines. The coordinates of the left vertical line is (-125, -105) and its length is 350.

The code to do this is shown below:

turtle.penup()
turtle.setheading(90)
turtle.setposition(-125, -105)
turtle.pendown()
turtle.forward(210)

The code to draw the other vertical line is shown below:

turtle.penup()
turtle.setheading(90)
turtle.setposition(125, -105)
turtle.pendown()
turtle.forward(210)

The generated image is shown below:


Drawing the diagonals is easy but we need to find the length of the diagonal and its angle.

Our first task is to find the angle between two points (-125, -105) and (125, 105). We will use the coordinateDistance function. The code for this 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:

diagonalLength = coordinateDistance(-125, -105, 125, 105)

The code to find the angle between the point is shown below:

myradians = math.atan2(105 - (-105), 125 - (-125))
angle = math.degrees(myradians)

We move the turtle to the position (-125, -105) and draw the line. The code to do this is shown below:

turtle.penup()
turtle.setposition(-125, -105)
turtle.setheading(angle)
turtle.pendown()
turtle.forward(diagonalLength)

The code to draw the other diagonal is given below:

turtle.penup()
turtle.setposition(125, -105)
turtle.setheading(180 - angle)
turtle.pendown()
turtle.forward(diagonalLength)

The generated image is shown below:


Drawing the serrated lines is easy. We simply need to move the turtle to that position and draw the lines.

The coordinate of the first line is (-175, 105) and it length is 50 pixels. The code to draw it is shown below:

turtle.penup()
turtle.setposition(-175, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

To draw the rest, we move the the pen by 50 pixels. The code to do this is shown below:

turtle.penup()
turtle.setposition(-125, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

The rest of the code for the upper part is shown below:

turtle.penup()
turtle.setposition(-75, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(-25, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(25, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(75, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(125, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(175, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)

The generated image is shown below:


To draw the lower part, we simply invert the coordinates of the y axis for the shape and change the heading of the turtle to 270.

The code to do this is shown below:

turtle.penup()
turtle.setposition(-175, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(-125, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(-75, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(-25, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(25, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(75, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(125, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(175, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)

The generated image is shown below:


To draw the left serrated edge, we will first draw the one at the center then figure out how to draw the rest.

The coordinates of the center are (-125, 0). We set its heading to 180 degrees and move forward by 50 pixels.

The code to do this is shown below:

turtle.penup()
turtle.setposition(-125, 0)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)

The generated image is shown below:


By extrapolation, the y coordinates of the remaining two horizontal lines are 52.5 and -52.5. The code to draw the remaining horizontal lines is given below:

turtle.penup()
turtle.setposition(-125, 52.5)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(-125, -52.5)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)

The generated image is shown below:


Drawing the right side is easy enough. The code to do so is shown below:

turtle.penup()
turtle.setposition(125, 0)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(125, 52.5)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)

turtle.penup()
turtle.setposition(125, -52.5)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)

The generated image is shown below:


Conclusion

At the end of this section, we have succeeded in drawing the Mrammuo 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.

Mpuankron


Mpuankron means "nine tufts of hair". It is the symbol of democracy.

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:
  1. Lift up the pen
  2. Move the pen to the location for the upper left square
  3. Draw the first square
  4. Repeat steps 1 -  3 for the other squares

Using Turtle Graphics

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

Before we can draw the first square, we need to draw two diagonals. To do this we borrow the code from Akoma Ntoaso project. We only need the diagonal length for the entire grid. This is 565.685424949.

The code below will draw the diagonal lines.

turtle.penup()
turtle.setposition(-200, -200)
turtle.setheading(45)
turtle.pendown()
turtle.forward(565.685424949)
turtle.penup()
turtle.setposition(200, -200)
turtle.setheading(135)
turtle.pendown()
turtle.forward(565.685424949)

The generated image is shown below:


The coordinates of the first square is (-175, 175). We will move the pen there and draw the square.

As we need to repeat the operation 9 times, we can best do it with a function. To create the function we only need the starting position of the function and the length of the square we want to draw.

Do bear in mind that the length of the square is 70 pixels.

The code for the function is shown below:

def drawFilledSquare(x, y, length):
    turtle.penup()
    turtle.setposition(x, y)
    turtle.begin_fill()
    turtle.setheading(0)
    turtle.forward(length)
    turtle.right(90)
    turtle.forward(length)
    turtle.right(90)
    turtle.forward(length)
    turtle.right(90)
    turtle.forward(length)
    turtle.right(90)
    turtle.end_fill()
To call the function, we simple pass in the parameters for the first square. The code for this is given below:

drawFilledSquare(-175, 175, 70)

The generated image is shown below:


The coordinates for the second, third, fourth and fifth squares are (-105, 105), (-35, 35), (35, -35) and (105, -105). The code to call the function is given below:

drawFilledSquare(-105, 105, 70)
drawFilledSquare(-35, 35, 70)
drawFilledSquare(35, -35, 70)
drawFilledSquare(105, -105, 70)

The generated image is shown below:


To complete the symbol, we need the coordinates for the remaining squares. Starting from the lower left hand side, the coordinates are: (-175, -105), (-105, -35), (35, 105) and (105, 175).

The code to call the function is shown below:

drawFilledSquare(-175, -105, 70)
drawFilledSquare(-105, -35, 70)
drawFilledSquare(35, 105, 70)
drawFilledSquare(105, 175, 70)

The generated image is shown below:


Conclusion

At the end of this section we have succeeded in drawing the Mpuankron symbol. You have to admit that it has a particular eerie beauty to it.

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.

Tuesday 10 April 2018

Mmara Krado


Mmara Krado is composed of two distinct words. "Mmara" means law and "Krado" means padlock. It is the symbol of the seal of law and order. It represents supreme authority and the court of justice.

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:
  1. Lift up the pen
  2. Set the pensize to 15 pixels
  3. Move the turtle to the left position of the inner semi-circle of the upper part of the symbol
  4. Set the heading to 90 degrees
  5. Place the pen down
  6. Draw the inner semi-circle
  7. Lift up the pen
  8. Move the turtle to the left position of the middle semi-circle of the upper part of the symbol
  9. Set the heading to 90 degrees
  10. Place the pen down
  11. Draw the middle semi-circle
  12. Lift up the pen
  13. Move the turtle to the left position of the outer semi-circle of the upper part of the symbol
  14. Set the heading to 90 degrees
  15. Place the pen down
  16. Draw the outer semi-circle
  17. Lift up the pen
  18. Move the turtle to the right position of the inner semi-circle of the lower part of the symbol
  19. Set the heading to 270 degrees
  20. Place the pen down
  21. Draw the inner semi-circle
  22. Lift up the pen
  23. Move the turtle to the right position of the middle semi-circle of the lower part of the symbol
  24. Set the heading to 270 degrees
  25. Place the pen down
  26. Draw the middle semi-circle
  27. Lift up the pen
  28. Move the turtle to the right position of the outer semi-circle of the lower part of the symbol
  29. Set the heading to 270 degrees
  30. Place the pen down
  31. Draw the outer semi-circle
  32. Lift up the pen
  33. Place the pen at the location for the leftmost part of the upper part of the symbol
  34. Set the heading to 0 degrees
  35. Place the pen down
  36. Move forward to cover the leftmost part of the upper part of the symbol
  37. Lift up the pen
  38. Move the pen to the location of the innermost part of the upper part of the symbol
  39. Place the pen down
  40. Move forward to cover the right of the upper part of the symbol
  41. Lift up the pen
  42. Place the pen at the location for the leftmost part of the lower part of the symbol
  43. Place the pen down
  44. Move forward to cover the leftmost part of the lower part of the symbol
  45. Lift up the pen
  46. Move forward over the gap between the two parts
  47. Place the pen down
  48. Move forward to cover the right of the lower part of the symbol
  49. Lift up the pen
  50. Move the pen to the left  location of the middle semi-circle
  51. Set the heading to 90 degrees
  52. Move forward to cover the gap
  53. Lift up the pen
  54. Move the pen to the right location of the middle semi-circle
  55. Move forward to cover the gap
Using Turtle Graphics

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

The coordinate left position of the inner semi-circle is (25, 50). Once we know this, we can write the code for steps 1 to 6.

The code for this is shown below:

turtle.penup()
turtle.pensize(30)
turtle.setposition(25, 50)
turtle.setheading(90)
turtle.pendown()
turtle.circle(25, 180)

The generated image is shown below:


The coordinate of the middle semi-circle is (75, 50). Knowing this value, we can draw the middle semi-circle. The code for steps 7 to 11 is shown below:

turtle.penup()
turtle.setposition(75, 50)
turtle.setheading(90)
turtle.pendown()
turtle.circle(75, 180)

The generated image is shown below:


The coordinate of the outer semi-circle is (125, 50). Knowing this value, we can draw the outer semi-circle. The code for steps 12 to 16 is shown below:

turtle.penup()
turtle.setposition(125, 50)
turtle.setheading(90)
turtle.pendown()
turtle.circle(125, 180)

The generated image is shown below:


The coordinate for the inner semi-circle of the lower part of the symbol is (-25, -50). The code for steps 17 to 21 is given below:

turtle.penup()
turtle.setposition(-25, -50)
turtle.setheading(270)
turtle.pendown()
turtle.circle(25, 180)

The generated image is shown below:


The coordinate for the middle semi-circle of the lower part of the symbol is  is (-75, -50). The code for steps 22 to 26 is given below:

turtle.penup()
turtle.setposition(-75, -50)
turtle.setheading(270)
turtle.pendown()
turtle.circle(75, 180)

The generated image is shown below:


The coordinate for the middle semi-circle of the lower part of the symbol is  is (-125, -50). The code for steps 27 to 31 is shown:

turtle.penup()
turtle.setposition(-125, -50)
turtle.setheading(270)
turtle.pendown()
turtle.circle(125, 180)

The generated image is shown below:


The location of the leftmost part of the upper part of the symbol is (-125, 40). The distance between this point and the location of the innermost part of the upper part of the symbol is 100.

The code for steps 32 to 36 is shown below:

turtle.penup()
turtle.setposition(-125, 40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(100)

The location of the innermost part of the upper part of the symbol is at (25, 40). The code for steps 37 to 40 is shown below:

turtle.penup()
turtle.setposition(25, 40)
turtle.pendown()
turtle.forward(100)

The generated image is shown below:


To draw the lower line, we simply repeat the steps we used to draw the upper line but now use the coordinates (-125, -40) and (25, -40).

The code to draw the lower line is shown below:

turtle.penup()
turtle.setposition(-125, -40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(25, -40)
turtle.pendown()
turtle.forward(100)

The generated image is shown below:


To draw the remaining lines we only need the coordinates of the left and right location of the middle semi-circle. These are (-75, -40) and (75, -40). The gap between the two lines is 80 pixels.

The code to complete the shape is shown below:

turtle.penup()
turtle.setposition(-75, -40)
turtle.setheading(90)
turtle.pendown()
turtle.forward(80)

turtle.penup()
turtle.setposition(75, -40)
turtle.setheading(90)
turtle.pendown()
turtle.forward(80)

The final symbol is shown below:


Conclusion

At the end of this section, we have managed to draw the Mmara Krado 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.

Sunday 8 April 2018

Menso Wo Kenten


Menso Wo Kenten means "I am not carrying your basket". It is the symbol of industry, self-reliance, and economic self-determination.

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:
  1. Get the coordinates of the starting points of the stars
  2. Lift up the pen
  3. Set the pen size to 10 pixels
  4. Move it to the starting point of the first star
  5. Place the pen down
  6. Move forward by the y coordinate of the star
  7. Find the angle between the turtle and the topmost part of the star
  8. Set the heading of the pen to angle
  9. Find the distance between the turtle and the topmost part of the star
  10. Move forward by the distance found
  11. Set the heading of the pen to the value of the 360 minus the angle
  12. Move forward by the distance found
  13. Set the heading of the pen to 0 degrees
  14. Move forward by the y coordinate of the star
  15. Find the angle between the turtle and the next position of the line
  16. Find the distance between the turtle and the line
  17. Set the heading of the pen to angle obtained in 15
  18. Move forward by distance obtained in 16
  19. Set the heading of the pen to value of 180 minus the value obtained in 15
  20. Move forward by the distance obtained in 16
  21. Set the heading of the pen to 180
  22. Move forward by the y coordinate of the star 
  23. Set the heading of the pen to value of the angle obtained in 7 minus 180 degrees
  24. Move forward by the distance obtained in 9
  25. Set the heading of the pen to the value of 180 minus the angle obtained in 7
  26. Move forward by the distance obtained in 9
  27. Set the heading of the pen to 180 degrees
  28. Move forward by the y coordinate of the first star
  29. Set the heading of the pen to 300 minus the value obtained in 15
  30. Move forward by the value obtained in 16
  31. Set the heading of the pen to 360 minus the value obtained in 15
  32. Move forward by the value obtained in 16
  33. Repeat steps 4 to 32 for the second star
  34. 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:


When we decide to draw the next star we don’t need to find the angles again. All we need are the distances for the star.
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:


To draw the outer star, we don’t need to do much we move the pen to is new position and find the value of the length from the position of the turtle to the topmost position.

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.