Mrammuo means "crossing paths". It is the symbol of life challenges.
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:
- Lift up the pen
- Set the pensize to 15 pixels
- Draw the outer box
- Draw the inner diagonals
- Draw the serrated edges
Using Turtle Graphics
We will use the template.py file and rename it to mrammuo.py.
The code to lift up the pen and set the pensize is shown below:
turtle.penup()
turtle.pensize(15)
The upper left coordinate for the outer box is (-175, 105). Its length is 350. The code to draw this line is given below:
turtle.setposition(-175, 105)
turtle.pendown()
turtle.forward(350)
We do the same for the lower part of the outer box. The code to do this is shown below:
turtle.penup()
turtle.setposition(-175, -105)
turtle.pendown()
turtle.forward(350)
The generated image is shown below:
To complete the box, we have to draw the vertical lines. The coordinates of the left vertical line is (-125, -105) and its length is 350.
The code to do this is shown below:
turtle.penup()
turtle.setheading(90)
turtle.setposition(-125, -105)
turtle.pendown()
turtle.forward(210)
The code to draw the other vertical line is shown below:
turtle.penup()
turtle.setheading(90)
turtle.setposition(125, -105)
turtle.pendown()
turtle.forward(210)
The generated image is shown below:
Drawing the diagonals is easy but we need to find the length of the diagonal and its angle.
Our first task is to find the angle between two points (-125, -105) and (125, 105). We will use the coordinateDistance function. The code for this 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 call the function using the code shown below:
diagonalLength = coordinateDistance(-125, -105, 125, 105)
The code to find the angle between the point is shown below:
myradians = math.atan2(105 - (-105), 125 - (-125))
angle = math.degrees(myradians)
We move the turtle to the position (-125, -105) and draw the line. The code to do this is shown below:
turtle.penup()
turtle.setposition(-125, -105)
turtle.setheading(angle)
turtle.pendown()
turtle.forward(diagonalLength)
The code to draw the other diagonal is given below:
turtle.penup()
turtle.setposition(125, -105)
turtle.setheading(180 - angle)
turtle.pendown()
turtle.forward(diagonalLength)
The generated image is shown below:
Drawing the serrated lines is easy. We simply need to move the turtle to that position and draw the lines.
The coordinate of the first line is (-175, 105) and it length is 50 pixels. The code to draw it is shown below:
turtle.penup()
turtle.setposition(-175, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
To draw the rest, we move the the pen by 50 pixels. The code to do this is shown below:
turtle.penup()
turtle.setposition(-125, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
The rest of the code for the upper part is shown below:
turtle.penup()
turtle.setposition(-75, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(-25, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(25, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(75, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(125, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(175, 105)
turtle.setheading(90)
turtle.pendown()
turtle.forward(50)
The generated image is shown below:
The code to do this is shown below:
turtle.penup()
turtle.setposition(-175, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(-125, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(-75, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(-25, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(25, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(75, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(125, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(175, -105)
turtle.setheading(270)
turtle.pendown()
turtle.forward(50)
The generated image is shown below:
The coordinates of the center are (-125, 0). We set its heading to 180 degrees and move forward by 50 pixels.
The code to do this is shown below:
turtle.penup()
turtle.setposition(-125, 0)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)
The generated image is shown below:
By extrapolation, the y coordinates of the remaining two horizontal lines are 52.5 and -52.5. The code to draw the remaining horizontal lines is given below:
turtle.penup()
turtle.setposition(-125, 52.5)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(-125, -52.5)
turtle.setheading(180)
turtle.pendown()
turtle.forward(50)
The generated image is shown below:
Drawing the right side is easy enough. The code to do so is shown below:
turtle.penup()
turtle.setposition(125, 0)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(125, 52.5)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.setposition(125, -52.5)
turtle.setheading(0)
turtle.pendown()
turtle.forward(50)
The generated image is shown below:
Conclusion
At the end of this section, we have succeeded in drawing the Mrammuo 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