(points,depth)
| 41 | return ( (p1[0]+p2[0]) / 2, (p1[1] + p2[1]) / 2) #find midpoint |
| 42 | |
| 43 | def triangle(points,depth): |
| 44 | |
| 45 | myPen.up() |
| 46 | myPen.goto(points[0][0],points[0][1]) |
| 47 | myPen.down() |
| 48 | myPen.goto(points[1][0],points[1][1]) |
| 49 | myPen.goto(points[2][0],points[2][1]) |
| 50 | myPen.goto(points[0][0],points[0][1]) |
| 51 | |
| 52 | if depth>0: |
| 53 | triangle([points[0], |
| 54 | getMid(points[0], points[1]), |
| 55 | getMid(points[0], points[2])], |
| 56 | depth-1) |
| 57 | triangle([points[1], |
| 58 | getMid(points[0], points[1]), |
| 59 | getMid(points[1], points[2])], |
| 60 | depth-1) |
| 61 | triangle([points[2], |
| 62 | getMid(points[2], points[1]), |
| 63 | getMid(points[0], points[2])], |
| 64 | depth-1) |
| 65 | |
| 66 | |
| 67 | triangle(points,int(sys.argv[1])) |
no test coverage detected