Wednesday 25 April 2018

Nsoromma


Nsoromma means "child of the heavens". It is the symbol of guardianship. A reminder that God is the father and watches over all people.

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 between the edge of the shape in the lower left quadrant and the top of the shape
  3. Find the distance between the edge of the shape in the lower left quadrant and the top of the shape
  4. Move the pen to the position of the lower left quadrant
  5. Set its heading to the value found in 2
  6. Move forward by the distance found in 3
  7. Continue alternating through steps 5 and 6 until the shape is completed
  8. Fill up the final shape
  9. Move to the rightmost position for the radius of the circle
  10. Draw a filled circle

Using Turtle Graphics

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

Step 1 is easy, we only need to lift up the pen. The code to do this is shown below:

turtle.penup()

For step 2 we need to find the angle between the lower left point of the symbol and its uppermost part. Their respective coordinates are (-140, -140) and (0, 195).

The code to do this is shown below:

turtle.penup()
myradians = math.atan2(195 - (-140), 0 - (-140))
angle = math.degrees(myradians)

The value of the angle will be used in drawing the entire shape.

Next we find the length between the two points using 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(-140, -140, 0, 195)

Steps 4 to 6 are easy enough. But we must use the fill property to draw the shape.

The code for the entire drawing is shown below:

turtle.setposition(-140, -140)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(angle)
turtle.forward(length)
turtle.setheading(360 - angle)
turtle.forward(length)
turtle.setheading(90 + angle)
turtle.forward(length)
turtle.setheading(90 - angle)
turtle.forward(length)
turtle.setheading(180 + angle)
turtle.forward(length)
turtle.setheading(180 - angle)
turtle.forward(length)
turtle.setheading(270 + angle)
turtle.forward(length)
turtle.setheading(270 - angle)
turtle.forward(length)
turtle.end_fill()

To really understand what is going on, add each setheading and forward combination gradually.

The generated image is shown below:



Drawing the circle is easy. We simply move the turtle to the position (50, 0), set its heading to 90 degrees and draw a filled circle.

The code to do this is shown below:

turtle.setposition(50, 0)
turtle.setheading(90)
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()

The generated image is shown below:


The only code that might appear strange is this line:

turtle.color("white", "white")

The above line makes the pencolor and fillcolor of the turtle white.

Conclusion

At the end of this section we have successfully drawn the Nsoromma symbol.

This is my favourite symbol in this series. It has an emergent property. It is made up of triangular shapes that combine to form it.

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