Friday 23 February 2018

Owo Foro Adobe


Owo Foro Adobe means "snake climbing the raffia tree". It is the symbol of steadfastness, prudence and diligence. Because of its thorns, the raffia tree is a very dangerous challenge to the snake. His ability to climb it is a model of persistence and prudence.

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


This symbol is easy to draw. It is just lines. The plan to draw the shape below is shown below:

  1. Lift up the pen
  2. Move the pen to the position (-170, -90)
  3. Set the pen size to 20 pixels
  4. Set the angle of the pen to 45 degrees
  5. Draw a line to the point (90, 170)
  6. Lift up the pen
  7. Move the pen to the position (-90, -170)
  8. Draw a line of the same length and heading as the first line you drew
  9. Lift up the pen
  10. Set the pen size to 5 pixels
  11. Draw the first zig zag line starting at (-170, -90)
  12. Draw the second zig zag line starting at (-160, -80)
  13. Draw the third zig zag line starting at (-150, -70)

Using Turtle Graphics

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

The code for the first four steps  is given below:

turtle.penup()
turtle.setposition(-170, -90)
turtle.pensize(20)
turtle.setheading(45)

The coordinateDistance function is used to find the distance between (-170, -90) and (90, 170). The code to do this is shown below:

inclineLength = coordinateDistance(-170, -90, 90, 170)

Now we place the pen down and move forward by the inclineLength. The code to do this is shown below:

turtle.pendown()
turtle.forward(inclineLength)

The generated image is shown below:


Now we are on step 6. The first step is to lift up the pen. Then we lift up the pen to the position (-90, -170). Next we set the heading of the pen and draw a line of the same length as the first line. The code to do this is shown below:

turtle.penup()
turtle.setposition(-90, -170)
turtle.setheading(45)
turtle.pendown()
turtle.forward(inclineLength)

The generated image is shown below:


Now we lift up the pen and move it back to the point (-170, -90). Next we need to set the pen size to 2 pixels and it heading to 0 degrees. The code to do this is shown below:

turtle.penup()
turtle.setposition(-170, -90)
turtle.pensize(5)
turtle.setheading(0)

Steps 13 to 15 repeat and would make a good candidate for a function. The use of this function will be to draw a zig zag line. This makes a good candidate for a function.

However, before we can create a function, we need to get the distance between two points on the line. Thankfully, with an angle of 45 degrees, all the length are equal so we only need to do this once.

The coordinateDistance function will be used to find the distance between (-170, -90) and (-10, -90). The code to do this is shown below:

rungLength = coordinateDistance(-170, -90, -10, -90)

The code for the zigZag function is given below:

def zigZag(x1, y1, distance):
    turtle.penup()
    turtle.setposition(x1, y1)
    turtle.pendown()
    turtle.setheading(0)
    turtle.forward(distance)
    turtle.setheading(90)
    turtle.forward(distance)
    turtle.setheading(0)
    turtle.forward(distance)
To call the function, all we need to do is to pass in the point we want it to get to and the distance we want it to move for. The code to do this is shown below:

zigZag(-170, -90, rungLength)
zigZag(-160, -80, rungLength)
zigZag(-150, -70, rungLength)

The generated image is shown below:


Conclusion

This symbol is one of the easier symbols to draw as it is made up of just lines.

No comments:

Post a Comment