ASm
ASm

Reputation: 389

Using recursion to draw patterns in python

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

enter image description here

What I needed help with was, is there a way to rotate the entire picture by 90 degrees? I tried starting the turtle off in a different angle (left by 90 degrees) and while this works for a depth of 1, it messed up a depth of 2.

Upvotes: 3

Views: 1107

Answers (1)

Stefan Pochmann
Stefan Pochmann

Reputation: 28646

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

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

Upvotes: 1

Related Questions