Wednesday 14 February 2018

Ntesie Mate Masie


Ntesie Mate Masie means "What I hear, I keep". It is the symbol of symbol of wisdom, knowledge and prudence.

We will use the 5 pixel grid to trace out this image. The image of this is shown below:


This symbol is simple to draw. We only need to know the position of the circles. We will use a function to prevent duplication.

The plan to draw this symbol is given below:
  1. Lift up the pen
  2. Move the position of the turtle to the position of the upper left quadrant
  3. Place the pen down
  4. Set the pen size to 20 pixels
  5. Draw the outer circle
  6. Set the pen size to 1 pixel
  7. Draw the inner circle
  8. Move the position of the turtle to the position of the lower left quadrant
  9. Repeat steps 3 to 7
  10. Move the position of the turtle to the position of the upper right quadrant
  11. Repeat steps 3 to 7
  12. Move the position of the turtle to the lower right quadrant
  13. Repeat steps 3 to 7
Using Turtle Graphics

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

The code for the first step is given below:

turtle.penup()

The position for the circle on the upper right quadrant is at (-90, 10). The code to move the turtle to this position is given below:

turtle.setposition(-90, 10)

The function to draw a portion of the symbol is given below:

def drawQuarterSymbol():
    turtle.pendown()
    turtle.pensize(20)
    turtle.circle(80)
turtle.setposition(turtle.xcor(), turtle.ycor() + 10)
    turtle.pensize(1)
    turtle.begin_fill()
    turtle.circle(40)
    turtle.end_fill()

The above function covers steps 3 to 7. We need to call the function. The code to call a function is given below:

drawQuarterSymbol()

The generated image is shown below:


From this point on, the rest is easy. All we need to do is to move the turtle to the point were we want to draw the quarter of the symbol.

The code for steps 8 and 9 is given below:

turtle.penup()
turtle.setposition(-90, -170)
drawQuarterSymbol()

The generated image is shown below:


To draw the quarter of the symbol, the turtle must be moved to the point that is (90, 10). The code to do this is shown below:

turtle.penup()
turtle.setposition(90, 10)
drawQuarterSymbol()

The generated image is shown below:


To draw the lower right symbol, we simply move the turtle to the position (90, -170) and draw the quarter of the symbol. The code to do this is shown below:

turtle.penup()
turtle.setposition(90, -170)
drawQuarterSymbol()

The generated image is shown below:


Conclusion

At the end, we have succeeded in drawing the Ntesie Mate Masie. Rather run the code 4 times, we could also have used a loop to draw the symbol.

Good programmers learn to watch out for this kind of things in their everyday work. However, this is a first draft so I will focus on drawing the symbols.

No comments:

Post a Comment