-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathpoints.py
31 lines (26 loc) · 872 Bytes
/
points.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
# -----------------------------------------------------------------------------
# Python & OpenGL for Scientific Visualization
# www.labri.fr/perso/nrougier/python+opengl
# Copyright (c) 2018, Nicolas P. Rougier
# Distributed under the 2-Clause BSD License.
# -----------------------------------------------------------------------------
import numpy as np
from glumpy import app, gloo, gl
vertex = """
attribute vec2 position;
void main() {
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
} """
fragment = """
void main() {
gl_FragColor = vec4(vec3(0.0), 1.0);
} """
window = app.Window(512, 512, color=(1,1,1,1))
points = gloo.Program(vertex, fragment, count=1000)
points["position"] = np.random.uniform(-1,1,(len(points),2))
@window.event
def on_draw(dt):
window.clear()
points.draw(gl.GL_POINTS)
app.run()