MCPcopy Index your code
hub / github.com/geekcomputers/Python / triangle

Function triangle

sierpinski_triangle.py:46–66  ·  view source on GitHub ↗
(points, depth)

Source from the content-addressed store, hash-verified

44
45
46def triangle(points, depth):
47 myPen.up()
48 myPen.goto(points[0][0], points[0][1])
49 myPen.down()
50 myPen.goto(points[1][0], points[1][1])
51 myPen.goto(points[2][0], points[2][1])
52 myPen.goto(points[0][0], points[0][1])
53
54 if depth > 0:
55 triangle(
56 [points[0], getMid(points[0], points[1]), getMid(points[0], points[2])],
57 depth - 1,
58 )
59 triangle(
60 [points[1], getMid(points[0], points[1]), getMid(points[1], points[2])],
61 depth - 1,
62 )
63 triangle(
64 [points[2], getMid(points[2], points[1]), getMid(points[0], points[2])],
65 depth - 1,
66 )
67
68
69triangle(points, int(sys.argv[1]))

Callers 1

Calls 3

getMidFunction · 0.85
upMethod · 0.80
downMethod · 0.80

Tested by

no test coverage detected