Thursday, 3 May 2018

Obohemmaa


Obohemmaa means "diamond". It is the symbol for precious items.

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. Find the angle and length between the leftmost position and the top of the symbol
  3. Draw the entire shape and fill it

Using Turtle Graphics

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

The code to lift up the pen is shown below:

turtle.penup()

The coordinate of the leftmost part of the symbol is (-100, 0). The coordinate for the topmost part of the symbol is (0, 200).

The code to find the angle is shown below:
myradians = math.atan2(200 - 0), 0 - (-100))
angle = math.degrees(myradians)

To find the distance between the two points we use the coordinateDistance function. The code for it 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:

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

The rest is easy. The code to draw the entire shape is shown below:

turtle.penup()
turtle.setposition(-100, 0)
turtle.begin_fill()
turtle.pendown()
turtle.setheading(angle)
turtle.forward(length)
turtle.setheading(360 - angle)
turtle.forward(length)
turtle.setheading(180 + angle)
turtle.forward(length)
turtle.setheading(180 - angle)
turtle.forward(length)
turtle.end_fill()

The generated image is shown below:


Conclusion

At the end of this section, we have succeeded in drawing the Obohemmaa 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