MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / triangle

Function triangle

other/sierpinski_triangle.py:43–64  ·  view source on GitHub ↗
(points,depth)

Source from the content-addressed store, hash-verified

41 return ( (p1[0]+p2[0]) / 2, (p1[1] + p2[1]) / 2) #find midpoint
42
43def 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
67triangle(points,int(sys.argv[1]))

Callers 1

Calls 1

getMidFunction · 0.85

Tested by

no test coverage detected