我是VisPy的新用户,并尝试从简单的示例开始(从教程中修改)。下面的代码在画布上绘制节点。 1.我如何绘制圆而不是点? 2.如何通过线路(随机或最近邻居或邻近r_max的邻居)连接这些节点?
import numpy as np
from vispy import app, scene
from vispy import gloo
c = app.Canvas(keys='interactive')
#c = scene.SceneCanvas(keys='interactive')
vertex = """
attribute vec2 a_position;
void main (void)
{
gl_Position = vec4(a_position, 0.0, 1.0);
}
"""
fragment = """
void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
"""
program = gloo.Program(vertex, fragment)
program['a_position'] = np.c_[
np.random.uniform(-0.5, +0.5, 1000).astype(np.float32),
np.random.uniform(-0.5, +0.5, 1000).astype(np.float32)]
@c.connect
def on_resize(event):
gloo.set_viewport(0, 0, *event.size)
@c.connect
def on_draw(event):
gloo.clear((0,0,0,1))
program.draw('points')
c.show()
app.run();