Thursday 19 April 2018

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.

No comments:

Post a Comment