Wednesday, 7 February 2018

Nkyimu


Nkyimu mean "the crossed divisions made on adinkra cloth before stamping". It is the symbol of symbol of skillfulness, precision.

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


This symbol is simple. It consists of lines. Note that angles between the lines are based on 45 degrees. The plan to draw this symbol is shown below:

  1. Set the pen size to 40 pixels
  2. Draw the outer square
  3. Draw all the lines working from the upper left quadrant

Using Turtle Graphics

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

The code for the first step of the algorithm is shown below:

turtle.pensize(40)

To draw the outer square, we can use the drawSquare function. The size of our square is 340 pixels. The code for this is given below:

drawSquare(340)

The generated image is shown below:


Step 3 of our algorithm is to draw all the lines working from the upper left quadrant. The lines are 20 in total.

Thankfully, 2 of each lines repeat in the shape so just have to identify which lines repeat and use the lengths of the lines.
To draw a line, we need to get its coordinates. Then we find the length of the line. We know that the angle between the lines is a multiple of 45 degrees so knowing its coordinates help us to know the distance between the lines.

The first line extends from (-120, 150) to (150, -120). To get the distance between the two points, we use the coordinateDistance function and assign the value it returns to a variable called firstLineLength. The code to do this is shown below:

firstLineLength = coordinateDistance(-120, 150, 150, -120)

To draw the line, we need to lift up the pen and move it to the point (-120, 150). Then we set the heading of the turtle to -45 degrees. We must reduce the pensize to 5 pixels and then we draw the first line. The code to do this is shown below:

turtle.penup()
turtle.setposition(-120, 150)
turtle.setheading(-45)
turtle.pensize(5)
turtle.pendown()
turtle.forward(firstLineLength)

The generated image is shown below:


Lines 2 to 4 are drawn in pretty much the same way. Since these lines are unique, I shall go through them together and show the code at the end.

Line 2 extends from (-140, 150) to (150, -140). The code to draw the line is given below:

turtle.penup()
secondLineLength = coordinateDistance(-140, 150, 150, -140)
turtle.setposition(-140, 150)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(secondLineLength)

Line 3 starts at (-150, 140). Its length is the same as that of the second line so we don’t need to calculate the length of this line. Our code will now be as shown below:

turtle.penup()
turtle.setposition(-150, 140)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(secondLineLength)

Line 4 starts at (-150, 120). Its lenght is the same as that of the first line so we don’t need to calculate its length. Our code will now be as shown below:

turtle.penup()
turtle.setposition(-150, 120)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(firstLineLength)

The generated image is shown below:


The next 4 lines will follow a similar pattern to be drawn. However, I will state that there is the need to get the values of the distance between the lines because these lines are unique.

To draw the fifth line, we note where it starts and where it ends. Once we know its length, we can then proceed to draw it.
The fifth line goes from (-150, 0) to (0, 150). The code to draw the line is given below:

turtle.penup()
fifthLineLength = coordinateDistance(-150, 0, 0, 150)
turtle.setposition(-150, 0)
turtle.setheading(45)
turtle.pendown()
turtle.forward(fifthLineLength)

The sixth line goes from (-150, -20) to (20, 150). The code to draw the line is given below:

turtle.penup()
sixthLineLength = coordinateDistance(-150, -20, 20, 150)
turtle.setposition(-150, -20)
turtle.setheading(45)
turtle.pendown()
turtle.forward(sixthLineLength)

The seventh line goes from (-150, -40) to (40, 150). The code to draw the line is given below:

turtle.penup()
seventhLineLength = coordinateDistance(-150, -40, 40, 150)
turtle.setposition(-150, -40)
turtle.setheading(45)
turtle.pendown()
turtle.forward(seventhLineLength)

The eight line goes from (-150, -60) to (60, 150). The code to draw the line is given below:

turtle.penup()
eightLineLength = coordinateDistance(-150, -60, 60, 150)
turtle.setposition(-150, -60)
turtle.setheading(45)
turtle.pendown()
turtle.forward(eightLineLength)

The generated image is shown below:


Drawing lines 9 to 12 will involve the same steps.

Line nine extends from (-150, -20) to (-20, -150). The code to draw the line is shown below:

turtle.penup()
ninthLineLength = coordinateDistance(-150, -20, -20, -150)
turtle.setposition(-150, -20)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(ninthLineLength)

Line ten extends from (-150, -40) to (-40, -150). The code to draw the line is shown below:

turtle.penup()
tenthLineLength = coordinateDistance(-150, -40, -40, -150)
turtle.setposition(-150, -40)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(tenthLineLength)

Line eleven extends from (-150, -60) to (-60, -150). The code to draw the line is shown below:

turtle.penup()
eleventhLineLength = coordinateDistance(-150, -60, -60, -150)
turtle.setposition(-150, -60)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(eleventhLineLength)

Line twelve extends from (-150, -80) to (-80, -150). The code to draw the line is shown below:

turtle.penup()
twelvethLineLength = coordinateDistance(-150, -80, -80, -150)
turtle.setposition(-150, -80)
turtle.setheading(-45)
turtle.pendown()
turtle.forward(twelvethLineLength)

The generated image is shown below:


Drawing lines 13 to 16 involves pretty much the same approach. However, I would note that line 13 is not the same length as any other line.

Line thirteen runs from (-80, -150) to (150, 80). The code to draw the line is shown below:

turtle.penup()
thirteenLineLength = coordinateDistance(-80, -150, 150, 80)
turtle.setposition(-80, -150)
turtle.setheading(45)
turtle.pendown()
turtle.forward(thirteenLineLength)

Line fourteen starts at (-60, -150). It has the same length as line eight so we use it. The code to draw this line is shown below:

turtle.penup()
turtle.setposition(-60, -150)
turtle.setheading(45)
turtle.pendown()
turtle.forward(eightLineLength)

Line fifteen starts at (-40, -150). It has the same length as line seven so we use it. The code to draw this line is shown below:

turtle.penup()
turtle.setposition(-40, -150)
turtle.setheading(45)
turtle.pendown()
turtle.forward(seventhLineLength)

Line sixteen starts at (-20, -150). It has the same length as line six so we use the length of line six. The code to draw this line is shown below:

turtle.penup()
turtle.setposition(-20, -150)
turtle.setheading(45)
turtle.pendown()
turtle.forward(sixthLineLength)

The generated image is shown below:


Drawing lines 17 to 20 will involve using a heading of 135 degrees. These lines are unique so we need to calculate their lengths.

To draw line seventeen, we must establish where it starts from and where it ends in order to get its distance. The line starts at (150, 20) and ends at (20, 150).

turtle.penup()
seventeenthLineLength = coordinateDistance(150, 20, 20, 150)
turtle.setposition(150, 20)
turtle.setheading(135)
turtle.pendown()
turtle.forward(seventeenthLineLength)

Line eighteen starts at (150, 40) and ends at (40, 150). The code to draw the line is shown below:

turtle.penup()
eighteenthLineLength = coordinateDistance(150, 40, 40, 150)
turtle.setposition(150, 40)
turtle.setheading(135)
turtle.pendown()
turtle.forward(eighteenthLineLength)

Line nineteen starts at (150, 60) and ends at (60, 150). The code to draw the line is shown below:

turtle.penup()
nineteenLineLength = coordinateDistance(150, 60, 60, 150)
turtle.setposition(150, 60)
turtle.setheading(135)
turtle.pendown()
turtle.forward(nineteenLineLength)

Line twenty starts at (150, 80) and ends at (80, 150). The code to draw the line is shown below:

turtle.penup()
twentiethLineLength = coordinateDistance(150, 80, 80, 150)
turtle.setposition(150, 80)
turtle.setheading(135)
turtle.pendown()
turtle.forward(twentiethLineLength)

The generated image is shown below:


Conclusion

At the end of this program, we have drawn the Nkyimu shape.

Monday, 5 February 2018

Nea Ope Se Obedi Hene


Nea Ope Se Obedi Hene means “He who wants to be king”. It is the symbol of symbol of service and leadership.

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


The symbol is complex. To draw it, we will need to use some of the techniques that we used to draw the Fawohudie symbol.

The plan to draw the shape is given below:

  1. Lift the pen up
  2. Set the pen size to 10 pixels
  3. Draw the outer 4 bounds
  4. Draw the outer square
  5. Draw the inner circles
  6. Draw the inner V shape
  7. Draw the parallel center vertical line
Using Turtle Graphics


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

The code for steps 1 and 2 are given below:

turtle.penup()
turtle.pensize(10)

The 4 bounds are in the 4 quadrants. We shall draw the 4 bounds starting with the one in the upper left quadrant.

To draw it, we need to move the mouse to its position (-185, 60), set its heading to 90 degrees and move 120 pixels forward. Next we change its heading to 0 degrees and move 120 pixels forward. The code to do this is shown below:

turtle.setposition(-185, 60)
turtle.setheading(90)
turtle.pendown()
turtle.forward(120)
turtle.setheading(0)
turtle.forward(120

To draw the upper right bound, we need to lift up our pen and move the mouse to the position (185, 60). Then we can repeat the steps we used to draw the upper left bound but change the heading to 180 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(185, 60)
turtle.setheading(90)
turtle.pendown()
turtle.forward(120)
turtle.setheading(180)
turtle.forward(120)

To draw the lower right bound, we need to lift up our pen and move the mouse to the position (185, -60). Then we can repeat the steps we used to draw the upper left bound but change the heading to 270 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(185, -60)
turtle.setheading(270)
turtle.pendown()
turtle.forward(120)
turtle.setheading(180)
turtle.forward(120)

To draw the lower left bound, we need to lift up our pen and move the mouse to the position (-185, -60). Then we can repeat the steps we used to draw the upper left bound but change the heading to 270 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(-185, -60)
turtle.setheading(270)
turtle.pendown()
turtle.forward(120)
turtle.setheading(0)
turtle.forward(120)

The generated image is shown below:


To draw the square, we simply use the drawSquare function. The size of the square is 330. So we pass it in as a parameter. The code to do this is shown below:

drawSquare(330)

The generated image is shown below:



To draw the first inner circle, we need to lift up the turtle and move it to the position that is 155 pixels from the center of the circle. Then we draw a circle of radius 155 pixels. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -155)
turtle.pendown()
turtle.circle(155)

The generated image is shown below:


The second circle is 125 pixels from the center of the symbol. We need to lift up the turtle and move it to the position that is 125 pixels from the center of the circle. Then we draw a circle of radius 125 pixels. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -125)
turtle.pendown()
turtle.circle(125)

The generated image is shown below:


To draw the leftward outer line, we need to draw a line from point (0, -155) to (-120, 10). We will use the coordinateDistance function defined earlier using Epa. The function definition 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 pass the distance between the two points into a variable called distanceLength. The code to do this is shown below:

distanceLength = coordinateDistance(0, -155, -120, 10)

We also need to find the angle between the two points. The code to do this is shown below:

myradians = math.atan2(10 - (-155), -120 - (0))
upperAngle = math.degrees(myradians)
turtle.setheading(upperAngle)

Once we have the angle between the two points and the length, we need to move the turtle to the point (0, -155) and draw the line. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -155)
turtle.pendown()
turtle.forward(distanceLength)

We now do the same for the right line. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -155)
turtle.setheading(180 -  upperAngle)
turtle.pendown()
turtle.forward(distanceLength)

The generated image is shown below:


To hide the point of intersection between the lines and the inner circle, we need to use a trick. I will move the turtle to the point (0, -140) and draw a triangle to connect points (20, -110) and (-20, -110). The pen colour will be set to white and I shall fill the triangle with a white colour. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -140)
turtle.color(“white”, “white”)
equalSide = coordinateDistance(0, -140, 20, -110)
myradians = math.atan2(-110 - (-140), 20 - (0))
upperAngle = math.degrees(myradians)
turtle.setheading(upperAngle)
turtle.begin_fill()
turtle.pendown()
turtle.forward(equalSide)
turtle.setheading(180)
turtle.forward(40)
turtle.setheading(-upperAngle)
turtle.forward(equalSide)
turtle.end_fill()

The generated image is shown below:


We shall now draw the left inner line. To draw it, we need to first change the pen colour of the mouse to black. Then move it to the position (0, -90). The value of the point on the left side we are trying to get to is (-110, 60). The code to do this is shown below:

turtle.penup()
turtle.pencolor(0, 0, 0)
turtle.setposition(0, -90)
distance = coordinateDistance(0, -90, -110, 60)
myradians = math.atan2(60 - (-90), -110 - (0))
upperAngle = math.degrees(myradians)
turtle.setheading(upperAngle)
turtle.pendown()
turtle.forward(distance)

We need to lift up the pen and move forward by 35 pixels, place the pen down and move forward by 60 pixels. The code to do this is shown below:

turtle.penup()
turtle.forward(35)
turtle.pendown()
turtle.forward(60)

We lift up the turtle and repeat the same sequence for the right. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -90)
turtle.setheading(180 - upperAngle)
turtle.pendown()
turtle.forward(distance)
turtle.penup()
turtle.forward(35)
turtle.pendown()
turtle.forward(60)

We will comment out the drawHorizontalLine and drawVerticalLine functions and see our creation in all its glory.

The generated image is shown below:


Conclusion

This was one of the harder symbols to draw. But at the end, we made it.

Friday, 2 February 2018

Nea Onnim No Sua A Ohu


Nea Onnim No Sua A Ohu means "He who does not know can know from learning". It is the symbol of knowledge, life-long education and continued quest for knowledge.

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


This shape is simple. It consists of lines. We simply have to get the coordinates from which we will be drawing the lines from.

The plan to draw the shape is shown below:

  1. Lift up the pen
  2. Set the pen size to 30
  3. Draw the vertical center lines
  4. Set the pen size to 20
  5. Draw the 3 horizontal center lines
  6. Draw all the vertical lines
  7. Draw all the horizontal lines
Using Turtle Graphics


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

The code for steps 1 and 2 are given below:

turtle.penup()
turtle.pensize(40)

To draw the first vertical line, we need to move the pen to the position (0, 50), set the heading of the turtle to 90 degrees, place the pen down and move it to the position (0, 160) by moving forward by 110 pixels. The code to do this is shown below:

turtle.setposition(0, 50)
turtle.setheading(90)
turtle.pendown()
turtle.forward(110)

The generated image is shown below:


To draw the second vertical line, we need to move the pen to the position (0, -40), set the heading of the turtle to 270 degrees, place the pen down and move it to the position (0, -160) by moving forward by 120 pixels. The code to do this is shown below:

turtle.penup()
turtle.setposition(0, -50)
turtle.setheading(270)
turtle.pendown()
turtle.forward(110)

The generated image is shown below:


To set the pen size to 20 we use the code shown below:

turtle.pensize(20)

To draw the three horizontal center lines, We need to move the mouse to the positions of the shape and move forward by 140 pixels. The position of the lines are at (-70, 40), (-70, 0) and (-70, -40). The code that does this is shown below:

turtle.penup()
turtle.setposition(-70, 40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)
turtle.penup()
turtle.setposition(-70, 0)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)
turtle.penup()
turtle.setposition(-70, -40)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)

The generated image is shown below:


We need to draw the six vertical lines as scaffolding for the symbol. The way to draw this would be to get to the upper part of the vertical lines and draw the line down.

The first two lines have the same length while the third line is the longest. The fourth line is the same length as the third line while the last 2 lines have the same length as the first two.

To draw these vertical lines, we need to lift the pen up and set its heading to 270 degrees. Then we can start drawing the vertical lines. The code to do this is shown below:

turtle.penup()
turtle.setheading(270)
turtle.setposition(-170, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(-120, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(-70, 180)
turtle.pendown()
turtle.forward(360)
turtle.penup()
turtle.setposition(170, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(120, 80)
turtle.pendown()
turtle.forward(160)
turtle.penup()
turtle.setposition(70, 180)
turtle.pendown()
turtle.forward(360)

The generated image is shown below:


The horizontal lines on the left are going to be drawn from the first to the last. The first and the last are longer than the others.

To draw the horizontal lines, we have to move the turtle and set its heading to 180 degrees. From there, we draw to the left of the shape. We draw the lines along the longest line. The code to do this is shown below:

turtle.penup()
turtle.setheading(180)
turtle.setposition(-70, 180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setposition(-70, 130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, 80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(-70, -180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setheading(0)
turtle.setposition(70, 180)
turtle.pendown()
turtle.forward(110)
turtle.penup()
turtle.setposition(70, 130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, 80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -80)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -130)
turtle.pendown()
turtle.forward(100)
turtle.penup()
turtle.setposition(70, -180)
turtle.pendown()
turtle.forward(110)

The generated image is shown below:


Conclusion

At the end of this section, we have successfully drawn the Nea Onnim No Sua A Ohu. It is easy to draw but requires a strategy before you start drawing.

Have a great weekend.

Wednesday, 3 January 2018

Mpuannum Nkotimsofo Puua


Mpuannum Nkotimsofo Puua means “Five tufts (of hair)”. It is the symbol of loyalty and priestly office.

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


This shape is simple. It consists of circles. We simply have to get the coordinates from which the drawing of our circles will take place.

The plan to draw the shape is shown below:

  1. Lift the pen
  2. Set the pen size to 20
  3. Draw the center circle
  4. Draw the upper left circle
  5. Draw the upper right circle
  6. Draw the lower left circle
  7. Draw the lower right circle
Using Turtle Graphics


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

The code for steps 1 and 2 are given below:

turtle.penup()
turtle.pensize(20)

The center circle is to be drawn first. Do keep in mind that it is a circle of radius 70 pixels. So we need to first lift up our turtle and move it to the position (0, -70). Then we draw a circle of 70 pixels. The code to do this is shown below:

turtle.setposition(0, -70)
turtle.pendown()
turtle.circle(70)

The generated image is shown below:


To draw the remaining shapes, we need to draw diagonal lines from one part of the grid to the other.

We borrow the code from Akoma Ntoaso project. We only need the diagonal length for the entire grid. This is 565.685424949.

The code below will draw the diagonal line.

turtle.penup()
turtle.setposition(-200, -200)
turtle.setheading(45)
turtle.pendown()
turtle.forward(565.685424949)
turtle.penup()
turtle.setposition(200, -200)
turtle.setheading(135)
turtle.pendown()
turtle.forward(565.685424949)

The generated image is shown below:


To draw the upper left circle, we need to get the coordinates of the point near the circle and place the turtle at that location. For our purposes, the coordinate of the point is (-60, 60). The heading of our turtle will be set to 45 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(-60, 60)
turtle.setheading(45)
turtle.pendown()
turtle.circle(70)

The generated image is shown below:


To draw the upper right circle, we need to get the coordinates of the point near the circle and place the turtle at that location. For our purposes, the coordinate of the point is (60, 60). The heading of our turtle will be set to -45 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(60, 60)
turtle.setheading(-45)
turtle.pendown()
turtle.circle(70)

The generated image is shown below:


To draw the lower right circle, we need to get the coordinates of the point near the circle and place the turtle at that location. For our purposes, the coordinate of the point is (60, -60). The heading of our turtle will be set to 45 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(60, -60)
turtle.setheading(225)
turtle.pendown()
turtle.circle(70)

The generated image is shown below:


To draw the lower left circle, we need to get the coordinates of the point near the circle and place the turtle at that location. For our purposes, the coordinate of the point is (-60, -60). The heading of our turtle will be set to 45 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(-60, -60)
turtle.setheading(135)
turtle.pendown()
turtle.circle(70)

The generated image is shown below:


Conclusion

We have successfully drawn the  Mpuannum Nkotimsofo Puua symbol.

Thursday, 14 December 2017

Mframadan


Mframadan means "wind resistant house". It is the symbol of symbol of fortitude and readiness to face life's vicissitudes.

This symbol suggests a reinforced or well-built home one built to withstand windy and treacherous conditions. It reflects in Asante history a clause in the unwritten constitutution of the Golden Stool.

Oral acocunts say that according to that clause, mud houses in Kumasi must be reinforced with turf. This reinforcing would cause the house to be sturdier and resistant to unfavorable weather conditions.

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 shown below:

  1. Lift the turtle
  2. Set the pen size to 10
  3. Draw the outer square
  4. Draw the inner square
  5. Draw the diagonal lines
  6. Draw the 4 remaining lines at the bottom
  7. Draw the 4 remaining lines at the top

Using Turtle Graphics

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

The code for steps 1 and 2 is given below:

turtle.penup()
turtle.pensize(15)

The outer square of the symbol is to be drawn first. Thankfully, we have the drawSquare function. Its length is 380 pixels. We use the drawSquare function to draw this shape by entering 380 as a parameter. The code for this is shown below:

drawSquare(380)

The generated image is shown below:


To draw the inner square, we also need to use the drawSquare function. The length of the square is 300 pixels. We use the drawSquare function to draw this shape by entering 300 as a parameter. The code to do this is shown below:

drawSquare(300)

The generated image is shown below:


To draw the diagonals that start at the lower left and move to the right quadrant, we must first get their positions.

To draw the lower line, we must move the turtle to its position and set is heading to 45 degrees. Then we move the turtle forward. The code to do this is shown below:

turtle.setposition(-110, -150)
turtle.setheading(45)
turtle.pendown()
turtle.forward(365)

The generated image is shown below:


Next we draw the upper left lower line. To do this, we move it to a position that is (-150, -110). We set the heading of the turtle to 45 degrees and we draw a line of length 365. The code to do this is shown below:

turtle.penup()
turtle.setposition(-150, -110)
turtle.setheading(45)
turtle.pendown()
turtle.forward(365)

The generated image is shown below:


Now we shall do the same thing for the right lines. The coordinates for the lower right lower line is (110, -150). Now that we know that, we shall repeat the steps we used to draw its counterpart only that its heading will be 135 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(110, -150)
turtle.setheading(135)
turtle.pendown()
turtle.forward(365)

We just do the same thing for the upper right lower line. Its coordinates are (150, -110). The code to draw it is given below:



Next we draw the bottom lines. The first bottom line starts at the position (-90, -130) and extends to the position (90, -130). The distance between the lines is 180 pixels. The code for this is shown below:

turtle.penup()
turtle.setposition(-90, -130)
turtle.setheading(0)
turtle.pendown()
turtle.forward(180)

The generated image is shown below:


The coordinates for the second bottom line are at (-70, -110). We need to draw a line of length 140. The code to do this is shown below:

turtle.penup()
turtle.setposition(-70, -110)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)

The generated image is shown below:


The coordinates for the third bottom line are at (-50, -90). We need to draw a line of length 100. The code to do this is shown below:

turtle.penup()
turtle.setposition(-50, -90)
turtle.setheading(0)
turtle.pendown()
turtle.forward(100)

The generated image is shown below:


The coordinates for the third bottom line are at (-30, -70). We need to draw a line of length 60. The code to do this is shown below:

turtle.penup()
turtle.setposition(-30, -70)
turtle.setheading(0)
turtle.pendown()
turtle.forward(60)

The generated image is shown below:


To draw the four top lines, we only need to reverse the along the y axis. So, the code to draw the four top lines is shown below:

turtle.penup()
turtle.setposition(-90, 130)
turtle.setheading(0)
turtle.pendown()
turtle.forward(180)

turtle.penup()
turtle.setposition(-70, 110)
turtle.setheading(0)
turtle.pendown()
turtle.forward(140)

turtle.penup()
turtle.setposition(-50, 90)
turtle.setheading(0)
turtle.pendown()
turtle.forward(100)

turtle.penup()
turtle.setposition(-30, 70)
turtle.setheading(0)
turtle.pendown()
turtle.forward(60)

The final shape is now shown below:


Conclusion

We have used Python Turtle Graphics to draw the Mframadan symbol. Now that the meaning is clear, I realize that the lines we drew last represents the rafters.

The entire symbol is symbolic of a roof viewed from above.

Tuesday, 12 December 2017

Me-Ware-Wo


Me-Ware-Wo means "I shall marry you". It is the symbol of commitment and perseverance.

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 shown below:
  1. Lift the turtle
  2. Set the pen size to 20 pixels
  3. Move the turtle to the position (-90, 10)
  4. Place the pen down
  5. Draw a circle of radius 80 pixels
  6. Set the heading of the turtle to 90 degrees
  7. Move forward by 50 pixels
  8. Change the heading of the turtle to 0 degrees
  9. Change the pen size to 1 pixel
  10. Draw a filled circle of radius 30 pixels
  11. Lift the pen
  12. Move the turtle to the position (90, 10)
  13. Set the pen size to 20 pixels
  14. Repeat steps 4 to 10
  15. Lift the pen
  16. Move the turtle to the position (90, -170)
  17. Set the pen size to 20 pixels
  18. Repeat steps 4 to 10
  19. Lift the pen
  20. Move the turtle to the position (-90, -170)
  21. Set the pen size to 20 pixels
  22. Repeat steps 4 to 10
Using Turtle Graphics

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

The code for steps 1 - 5 is given below:

turtle.penup()
turtle.pensize(20)
turtle.setposition(-90, 10)
turtle.pendown()
turtle.circle(80)

The generated image is shown below:


The code for steps 6 to 10 is given below:

turtle.setheading(90)
turtle.forward(50)
turtle.setheading(0)
turtle.pensize(1)
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()

The generated image is shown below:


Steps 14, 18 and 22 are repeated. This would be a good candidate for a function. So we create a function called draw_quarter_symbol and place it just after drawVertical function.

The code for the draw_quarter_symbol is shown below:

def draw_quarter_symbol():
    turtle.pendown()
    turtle.circle(80)
    turtle.setheading(90)
    turtle.forward(50)
    turtle.setheading(0)
    turtle.pensize(1)
    turtle.begin_fill()
    turtle.circle(30)
    turtle.end_fill()

This step we have carried out is called refactoring. The code that draws our symbol now becomes:

turtle.penup()
turtle.pensize(20)
turtle.setposition(-90, 10)
draw_quarter_symbol()

Run the above code and test it. The program runs as expected. To draw the rest of the symbol, you only need to copy and paste the code above 3 more times. Then you change the position you move your turtle to.

The code for our program now becomes:

turtle.penup()
turtle.pensize(20)
turtle.setposition(-90, 10)
draw_quarter_symbol()
turtle.penup()
turtle.pensize(20)
turtle.setposition(90, 10)
draw_quarter_symbol()
turtle.penup()
turtle.pensize(20)
turtle.setposition(90, -170)
draw_quarter_symbol()
turtle.penup()
turtle.pensize(20)
turtle.setposition(-90, -170)
draw_quarter_symbol()

The generated image is shown below:


Conclusion

At the end of this section, we have used the Python language to draw the Adinkra symbol Me Ware Wo.