@Annvil/

# FractalTriangle

## No description

main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
```
```import turtle

# define the draw points function (same as above)
def drawShape(points):
fractal.penup()
fractal.goto(points[0][0],points[0][1]) # point0.x, point0.y
fractal.pendown()
fractal.begin_fill()
for point in points:
fractal.goto(point[0],point[1])
fractal.goto(points[0][0],points[0][1]) # Close shape
fractal.end_fill()
fractal.penup

def getMid(p1, p2):
# Return the midpoint between p1 and p2
return ( float(p1[0]+p2[0]) / 2, float(p1[1] + p2[1]) / 2)

def drawRecursive(points,depth):
#print(depth, points)

if depth == 0:
return

drawRecursive([points[0], getMid(points[0], points[1]), getMid(points[0], points[2])], depth-1)
drawRecursive([points[1], getMid(points[0], points[1]), getMid(points[1], points[2])], depth-1)
drawRecursive([points[2], getMid(points[2], points[0]), getMid(points[2], points[1])], depth-1)

drawShape([getMid(points[0], points[1]), getMid(points[1], points[2]), getMid(points[2], points[0])])

fractal = turtle.Turtle()
fractal.speed(0)

triangle_points = [[-250,-175],[0,250],[250,-175]]

fractal.color("black", "black")
drawShape(triangle_points)

fractal.color("black", "white")
drawRecursive(triangle_points, 6)
```
result
console