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.


No comments:

Post a Comment