mirror of
https://github.com/finninde/vispy-kurs.git
synced 2025-07-08 05:22:50 +02:00
La til kurskoden, samt foiler
This commit is contained in:
37
kurs1.py
Normal file
37
kurs1.py
Normal file
@ -0,0 +1,37 @@
|
||||
import numpy as np
|
||||
from vispy import app
|
||||
from vispy import gloo
|
||||
|
||||
vertex = """
|
||||
attribute vec2 a_position;
|
||||
void main (void)
|
||||
{
|
||||
gl_Position = vec4(a_position, 0.0, 1.0);
|
||||
}
|
||||
"""
|
||||
|
||||
fragment = """
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
"""
|
||||
|
||||
c = app.Canvas(keys='interactive')
|
||||
program = gloo.Program(vertex, fragment)
|
||||
|
||||
program['a_position'] = np.float32(np.c_[
|
||||
np.linspace(-1.0, +1.0, 1000),
|
||||
np.random.uniform(-0.5, +0.5, 1000)])
|
||||
|
||||
@c.connect
|
||||
def on_resize(event):
|
||||
gloo.set_viewport(0, 0, *event.size)
|
||||
|
||||
@c.connect
|
||||
def on_draw(event):
|
||||
gloo.clear((1,1,1,1))
|
||||
program.draw('line_strip')
|
||||
|
||||
c.show()
|
||||
app.run()
|
Reference in New Issue
Block a user