Using recursion to draw templates in python

I was looking at this web page http://openbookproject.net/thinkcs/python/english3e/recursion.html and there is a good recursive solution for drawing a tree, so I decided to write the code myself to draw this "H-tree" below ...

enter image description here

I needed help, is there a way to rotate the whole picture 90 degrees? I tried to release the turtle at a different angle (to the left 90 degrees) and while this works for depth 1, it messed up depth 2.

+3


source to share


1 answer


Yes, just rotate before drawing outside of the recursive function:



window = turtle.Screen()
turtle.right(90)
drawHTree(200,2)

      

+1


source







All Articles