-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkofrac
More file actions
executable file
·124 lines (117 loc) · 2.1 KB
/
kofrac
File metadata and controls
executable file
·124 lines (117 loc) · 2.1 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
import turtle
from turtle import *
def drawKoch(t, order, size):
if order == 0:
t.forward(size)
else:
drawKoch(t, order-1, size/3)
t.left(60)
drawKoch(t, order-1, size/3)
t.right(120)
drawKoch(t, order-1, size/3)
t.left(60)
drawKoch(t, order-1, size/3)
def koch(t, order, size):
drawKoch(t, order, size)
t.right(270)
drawKoch(t,order, size)
t.right(270)
drawKoch(t, order, size)
t.right(270)
drawKoch(t, order, size)
def koch2(t, order, size):
drawKoch(t,order, size)
t.right(60)
drawKoch(t, order, size)
t.right(60)
drawKoch(t, order, size)
t.right(60)
drawKoch(t,order, size)
t.right(60)
drawKoch(t, order, size)
t.right(60)
drawKoch(t,order, size)
screen = Screen()
screen.setup(640,640)
screen.title('Koch Fractal')
screen.bgcolor('#333333')
t = turtle.Turtle()
t.hideturtle()
t.speed(10)
t.penup()
t.setx(-5)
t.sety(0)
t.pendown()
t.color('#1793d1')
t2 = turtle.Turtle()
t2.hideturtle()
t2.speed(10)
t2.penup()
t2.setx(-5)
t2.sety(0)
t2.pendown()
t2.color('#9966CC')
t3 = turtle.Turtle()
t3.hideturtle()
t3.speed(10)
t3.penup()
t3.setx(-5)
t3.sety(0)
t3.pendown()
t3.color('#FF7E00')
t4 = turtle.Turtle()
t4.hideturtle()
t4.speed(10)
t4.penup()
t4.setx(-5)
t4.sety(0)
t4.pendown()
t4.color('#0BDA51')
t5 = turtle.Turtle()
t5.hideturtle()
t5.speed(10)
t5.penup()
t5.setx(-5)
t5.sety(0)
t5.pendown()
t5.color('#DF00FF')
t6 = turtle.Turtle()
t6.hideturtle()
t6.speed(10)
t6.penup()
t6.setx(-5)
t6.sety(0)
t6.pendown()
t6.color('#CC3333')
koch2(t5, 3, 100)
koch2(t5, 3, 100)
koch2(t5, 3, 100)
koch2(t5, 3, 100)
koch2(t5, 3, 100)
koch2(t5, 3, 100)
koch2(t6, 3, 150)
koch2(t6, 3, 150)
koch2(t6, 3, 150)
koch2(t6, 3, 150)
koch2(t6, 3, 150)
koch2(t6, 3, 150)
koch2(t3, 3, 50)
koch2(t3, 3, 50)
koch2(t3, 3, 50)
koch2(t3, 3, 50)
koch2(t3, 3, 50)
koch2(t3, 3, 50)
koch(t4, 4, 400)
koch(t4, 4, 400)
koch(t4, 4, 400)
koch(t4, 4, 400)
koch(t2, 4, 300)
koch(t2, 4, 300)
koch(t2, 4, 300)
koch(t2, 4, 300)
koch(t, 4, 200)
koch(t, 4, 200)
koch(t, 4, 200)
koch(t, 4, 200)
turtle.mainloop()