## 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.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()
drawTong()
drawTong()
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.