Friday 30 March 2018

Kuronti ne Akwamu


Kuronti ne Akwamu means “Kuronti and Akwamu”. It is the symbol of democracy, sharing ideas, taking council. The Centre for Democratic Development (CDD) in Ghana holds an annual lecture series called the Kronti ne Akwamu Lecture to discuss issues related to democratic development.

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 20 pixels
  3. Draw the outer square
  4. Draw the center lines
  5. Set the pensize to 5 pixels
  6. Draw the serrated lines in the upper left box
  7. Draw the serrated lines in the lower right box

Using Turtle Graphics

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

The code for steps 1 and 2 is given below:

turtle.penup()
turtle.pensize(20)

To draw the square, we need to find the length from (-180, 180) to (180, 180). This will enable us draw the square.

To do this, we use the coordinateDistance function which is shown below:

def coordinateDistance(x1, y1, x2, y2):
dx = x1 - x2
dy = y1 - y2
D = math.sqrt((dx * dx) + (dy * dy))
return D

The code to find the length of the side is given below:

length = coordinateDistance(-180, 180, 180, 180)

The drawSquare function is now used to draw the square. The code to do this  is given below:

drawSquare(length)

The generated image is shown below:


To draw the center lines, we have to move the turtle to the left hand side and move forward by the length of the side. Next we move the turtle to the bottom, set its heading to 90 degrees and move up by the length of the side. The code to do this is shown below:

turtle.setposition(-180, 0)
turtle.pendown()
turtle.forward(length)
turtle.penup()
turtle.setheading(90)
turtle.setposition(0, -180)
turtle.pendown()
turtle.forward(length)

The generated image is shown below:


Drawing the serrated lines is sort of tricky. This is because we have to draw them 15 times in either direction. To do this, we will use two functions. One for the horizontal lines and the other for the vertical lines.

The code to draw the vertical lines is given below:

def drawVerticalLines(x1, y1, division, space, length):
for line in range(0, division):
turtle.penup()
turtle.setposition(x1, y1)
x1 = x1 + space
turtle.pendown()
turtle.forward(length)
The code to use it is simple and straightforward. It is shown below:

turtle.pensize(5)
length = int(length / 2)
drawVerticalLines(-160, 0, 15, 10, length)

The generated image is shown below:


To draw the horizontal lines on the upper left box, we create a function called drawHorizontalLines and use it. The code for drawHorizontalLines is shown below:

def drawHorizontalLines(x1, y1, division, space, length):
for line in range(0, division):
        turtle.penup()
        turtle.setposition(x1, y1)
        y1 = y1 + space        
        turtle.pendown()
        turtle.forward(length)
To draw the horizontal lines, we use the code shown below:

turtle.setheading(0)
drawHorizontalLines(-180, 20, 15, 10, length)

The generated image is shown below:


To draw the serrated lines for the lower right box, we only need the starting coordinates for the horizontal
and vertical lines which are (20, -180) and (0, -160).

The code to draw the vertical lines is shown below:

turtle.setheading(90)
drawVerticalLines(20, -180, 15, 10, length)

The code to draw the horizontal lines is shown below:

turtle.setheading(0)
drawHorizontalLines(0, -160, 15, 10, length)

The generated image is shown below:


Conclusion

We have succeeded in drawing the Kuronti ne Akwamu 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.

Thursday 29 March 2018

Abusua Pa


Abusua Pa means "Good Family". It is the symbol for the family unit.

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. Increase the pensize to 40
  3. Move it to the lower left hand corner of the outer square (-100, -100)
  4. Place the pen down
  5. Move forward to the position (100, -100)
  6. Turn left by 90 degrees
  7. Repeat steps 5 and 6 3 times
  8. Draw the center lines
  9. Draw the outer circles
  10. Reduce the pensize to 5
  11. Draw the inner squares
Using Python Turtle

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

The code for steps 1 and 2 is given below:

turtle.penup()
turtle.pensize(40)

To move the pen to the lower left hand corner, we have to use the setposition function. The position we want to move it to is (-10, -10). The code to do this is shown below:

turtle.setposition(-100, -100)
turtle.pendown()

To find the distance between to points, we use the coordinateDistance function which 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 calculate the length between the two points using the code shown below:

length = coordinateDistance(-100, -100, 100, -100)

Rather than repeat steps 5, 6 and 7 we shall use the drawSquare function. The code to do this is shown below:

drawSquare(length)

For this to work, we need to comment out the turtle.reset command in the drawSquare function. The generated image is now shown below:


I realize that since we are using the drawSquare function, we no longer need the setposition code. We can comment it out.

To draw the center lines, we have to move the turtle to the left hand side and move forward by the length of the side. Next we move the turtle to the bottom, set its heading to 90 degrees and move up by the length of the side. The code to do this is shown below:

turtle.setposition(-100, 0)
turtle.pendown()
turtle.forward(length)
turtle.penup()
turtle.setheading(90)
turtle.setposition(0, -100)
turtle.pendown()
turtle.forward(length)

The generated image is shown below:


To draw the outer circle we will start with the top and move clockwise. To draw the upper circle, we need to move the turtle to the position (60, 120). Then we draw the semi-circle. The code to do this is shown below:

turtle.penup()
turtle.setposition(50, 120)
turtle.pendown()
turtle.circle(50, 180)

The generated image is shown below:


To draw the remaining semi-circles, we move clockwise and also change the heading of our turtle accordingly. The code to do this is shown below:

turtle.penup()
turtle.setposition(120, -50)
turtle.setheading(0)
turtle.pendown()
turtle.circle(50, 180)

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

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

The generated image is shown below:


Completing this shape is easy. All we have to do is draw the lines that are within the squares. To do this we must reduce the pensize to 5 and set the orientation of the turtle appropriately to draw the lines.

The code to do this is shown below:

turtle.penup()
turtle.pensize(5)
turtle.setposition(-60, -100)
turtle.setheading(90)
turtle.pendown()
turtle.forward(length)

turtle.penup()
turtle.setposition(-40, -100)
turtle.setheading(90)
turtle.pendown()
turtle.forward(length)

turtle.penup()
turtle.setposition(40, -100)
turtle.setheading(90)
turtle.pendown()
turtle.forward(length)

turtle.penup()
turtle.setposition(60, -100)
turtle.setheading(90)
turtle.pendown()
turtle.forward(length)

The generated image is shown below:


To draw the remaining horizontal lines, I shall start from the bottom of the symbol and work my way up the code to do this is shown below:

turtle.penup()
turtle.setposition(-100, -60)
turtle.setheading(0)
turtle.pendown()
turtle.forward(length)

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

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

turtle.penup()
turtle.setposition(-100, 60)
turtle.setheading(0)
turtle.pendown()
turtle.forward(length)

The generated image is shown below:


Conclusion

We have successfully drawn the Abusua Pa symbol using the Python programming language. I would comment that it is a truly beautiful 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.


Monday 19 March 2018

Aban


Aban means "fortress". It is the symbol of strength and authority.

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 heading to 45 degrees
  3. Move the pen to the start position of the shape
  4. Set the pen size to half of the width of the shape
  5. Place the pen down
  6. Move forward to draw the first line
  7. Turn right by 90 degrees
  8. Move forward to draw half of the first line
  9. Turn left by 90 degrees
  10. Move forward to draw the protruding line at a distance of 5/8 of the length
  11. Lift up the pen
  12. Reverse the turtle by moving back the same distance as you moved forward
  13. Turn right by 90 degrees
  14. Place the pen down
  15. Draw the second half of the line
  16. Turn right by 90 degrees
  17. Move forward to draw the third line
  18. Repeat steps 6 to 17 3 more times
Using Turtle Graphics

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

The code for steps 1 to 3 is given below:

turtle.penup()
turtle.setheading(45)
turtle.setposition(0, 80)

Since in step 15 the shape is draw 3 times, it is a good candidate for a function. I will call the function drawTong because a single piece of the shape looks like a tong.

Before we can use a function, the values we need to find are the width of the line, its length and the length of its protrusion.

To find the width of the line, we need to find the distance between two parallel points it passes through and this are: (120, 0) and (40, 80).

It starts at the point (0, 80) and moves at an angle of 45 degrees to the point (80, 160).

The protrusion is the size of the width of the shape.

To get the width and length of the shape, we will use the coordinateDistance function which is shown below:

def coordinateDistance(x1, y1, x2, y2):
dx = x1 - x2
dy = y1 - y2
D = math.sqrt((dx * dx) + (dy * dy))
return D

To find the width and length, we use the expressions below:

width = coordinateDistance(120, 0, 40, 80)
length = coordinateDistance(0, 80, 80, 160)

The code for steps 4 and 5 is shown below:

turtle.pensize(width)
turtle.pendown()

Steps 6 to 16 can be automated using the drawTong function. We will first write out the commands for the steps to check then we will later integrate them into the drawTong function.

The code for steps 6 to 10 is given below:

turtle.forward(length)
turtle.right(90)
turtle.forward(length / 2)
turtle.left(90)
turtle.forward(length * 5 / 8)

The generated image is shown below:


The code to lift the pen is straightforward enough. To reverse the shape, we need to move backward the same number of steps as forward.

The code to do this is shown below:

turtle.penup()
turtle.backward(length * 5 / 8)
turtle.right(90)
turtle.pendown()
turtle.forward(length / 2)
turtle.right(90)
turtle.forward(length)

The generated image is shown below:


Now that we have drawn on part of the symbol, we can use the code to create the drawTong function so that we don’t have to repeat ourselves.

The code for the function is shown below:

def drawTong():
    turtle.forward(length)
    turtle.right(90)
    turtle.forward(length / 2)
    turtle.left(90)
    turtle.forward(length * 5 / 8)
    turtle.penup()
    turtle.backward(length * 5 / 8)
    turtle.right(90)
    turtle.pendown()
    turtle.forward(length / 2)
    turtle.right(90)
    turtle.forward(length)

To draw the shape completely, we need to call this function and alternate with the setheading angle that is representative of the quadrant the function draws in. The code to do this is shown below:

drawTong()
turtle.setheading(315)
drawTong()
turtle.setheading(225)
drawTong()
turtle.setheading(135)
drawTong()

The generated image is shown below:


Conclusion

At the end of this section, we have drawn the completed Aban symbol. I would advise you to go over the code and ensure you understand what each part of the code is doing.

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.

Monday 12 March 2018

The Series Continues


Above is the Biafran flag. You would be hard pressed to convince me that the Owia A Repue symbol was not the inspiration for it. Owia A Repue is shown below:


Owia A Repue means "Rising Sun". It is the symbol of progress, renewal, development, warmth, vitality, and energy.

After writing the Conclusion last week, I actually thought I was done with this series.

In my mind, I thought I could kick back and relax but that was not to be the case.

In placing the series out there, I got feedback and found this link which contains a list of 129 Adinkra symbols.

The hardwork would be going through the list and finding the symbols that could be drawn using Python turtle. At the end, I have decided that 17 more symbols could be drawn.

So the series continues.