-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodes.py
45 lines (33 loc) · 1.14 KB
/
modes.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
import time
from utilities.globals import circles, batch, lines
import pyglet
CHEMISTRY = 0
POLYGONS = 1
def connect_all(mode: int):
_map = {CHEMISTRY : connect_chemistry,
POLYGONS : connect_polygons}
_map[mode]()
def connect_chemistry():
global circles, batch, lines
connected = set()
for node in circles:
for other in node.neighbors:
if other not in connected:
vertex_list = pyglet.graphics.vertex_list(2,
('v2f', (node.x, node.y, other.x, other.y))
)
vertex_list.draw(pyglet.gl.GL_LINES)
vertex_list.delete()
connected.add(other)
def connect_polygons():
global circles, batch, lines
connected = set()
for node in circles:
for other in node.neighbors:
if (node, other) not in connected:
vertex_list = pyglet.graphics.vertex_list(2,
('v2f', (node.x, node.y, other.x, other.y))
)
vertex_list.draw(pyglet.gl.GL_LINES)
vertex_list.delete()
connected.add((node, other))