forked from jvan/vroom-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquakes.vroom
More file actions
executable file
·52 lines (35 loc) · 1.03 KB
/
quakes.vroom
File metadata and controls
executable file
·52 lines (35 loc) · 1.03 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
#!/usr/bin/env vroom-wrapper
from vroom import *
# vroom callbacks
def init():
vertices = []
colors = []
filename = get_resource('earthquakes-2010.dat')
data = open(filename).readlines()[2:]
Global.labels = []
for row in data:
elems = row.split()
epicenter = map(float, elems[2:5])
vertices.append(epicenter)
magnitude = float(elems[5])
if magnitude > 3.5:
colors.append([1.0, 0.0, 0.0, 0.4])
else:
colors.append([0.0, 1.0, 0.0, 0.4])
if magnitude > 4.0:
Global.labels.append(('{:.1f}'.format(magnitude), epicenter))
Global.points = PointCloud(vertices, colors)
Global.center = center(vertices)
def gl_init():
spriteFile = get_resource('particle.bmp')
Global.points.sprite(spriteFile)
fontFile = get_resource('fonts/DroidSans.ttf')
textFont(fontFile)
def display():
lighting(False)
pushMatrix()
translate(Global.center)
Global.points.draw()
for (label, pos) in Global.labels:
text(label, pos)
popMatrix()