-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchaos_tri.py
55 lines (39 loc) · 1015 Bytes
/
chaos_tri.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# chaos_tri.py
import random as rand
import pygame as pg
import time
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
screen_size = (700, 500)
to_update = []
points = ((350, 10), (10, 490), (690, 490))
time = 2
size = 1
p = (200, 200)
pg.init()
screen = pg.display.set_mode(screen_size)
screen.fill(white)
for i in points:
pg.draw.circle(screen, red, i, 7, 0)
pg.display.update()
def find_new(old, corner, fraction):
a = int(old[0] * (1 - fraction) + fraction * corner[0])
b = int(old[1] * (1 - fraction) + fraction * corner[1])
return a, b
count = 0
while count < 200:
print(count)
if pg.event.get() == pg.QUIT:
pg.quit()
quit()
for i in range(100):
chosen = rand.choice(points)
p = find_new(p, chosen, 1/2)
pg.draw.circle(screen, black, p, size, 0)
to_update.append((p[0] - size, p[1] - size, 2*size, 2*size))
pg.display.update(to_update)
del to_update[:]
pg.time.wait(20)
count += 1
pg.time.wait(20000)