We will use the 5 pixel grid to trace out this image. The image of this is shown below:
- Lift up the pen
- Set the pensize to 20 pixels
- Draw the outer square
- Draw the center lines
- Set the pensize to 5 pixels
- Draw the serrated lines in the upper left box
- 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.
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.