gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
    polygon.draw(gl.GL_TRIANGLE_FAN)

    gl.glLineWidth(1.0)
    polygon["color"] = 0.50, 0.50, 0.50, 1.00
    gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
    polygon.draw(gl.GL_TRIANGLE_FAN)

    gl.glLineWidth(3.0)
    polygon["color"] = 0.00, 0.00, 0.00, 1.00
    polygon.draw(gl.GL_LINE_LOOP, O)

    points.draw()


np.random.seed(1)
P = 0.95 * np.random.uniform(-1, 1, (50, 3))

H = P[scipy.spatial.ConvexHull(P[:, :2]).vertices]
points = MarkerCollection(marker="disc")
points.append(H, bg_color=(1, 1, 1, 1), size=16)
points.append(P, bg_color=(0, 0, 0, 1), size=4)

P = P[scipy.spatial.ConvexHull(P[:, :2]).vertices]
polygon = gloo.Program(vertex, fragment, count=len(P))
polygon["position"] = P
O = scipy.spatial.ConvexHull(P[:, :2]).vertices
O = O.astype(np.uint32).view(gloo.IndexBuffer)

app.run()
Пример #2
0
    v_fg_color    = fg_color;
    v_bg_color    = bg_color;
    v_orientation = vec2(cos(orientation), sin(orientation));

    gl_Position = <transform(position)>;
    float scale = (3.5 - length(gl_Position.xyz)/length(vec3(1.5)));
    v_fg_color.a = scale;
    v_bg_color.a = scale;
    scale=1;
    v_size       = scale * size;
    gl_PointSize = M_SQRT2 * size * scale + 2.0 * (linewidth + 1.5*antialias);
    <viewport.transform>;
}
"""

markers = MarkerCollection(marker="disc", vertex=vertex,
                           viewport = viewport, transform=transform)
C, La, Lo = [], [], []
with open(data.get("capitals.csv"), 'r') as file:
    reader = csv.reader(file, delimiter=',')
    next(reader, None) # skip the header
    for row in reader:
        capital = row[1]
        latitude = np.pi/2 + float(row[2])*np.pi/180
        longitude = np.pi  + float(row[3])*np.pi/180
        C.append(capital)
        La.append(latitude)
        Lo.append(longitude)
P = spheric_to_cartesian(Lo, La, radius*1.01)
markers.append(P, bg_color = (1,1,1,1), fg_color=(.25,.25,.25,1), size = 10)

Пример #3
0
import numpy as np
from glumpy import app
from glumpy.graphics.collections import MarkerCollection

window = app.Window(1024, 1024, color=(1, 1, 1, 1))


@window.event
def on_draw(dt):
    window.clear()
    markers.draw()
    markers['orientation'] += np.random.uniform(0.0, 0.1, len(markers))
    del markers[0]
    if not len(markers):
        app.quit()


n = 256
markers = MarkerCollection(orientation='local')
markers.append(np.random.uniform(-1, 1, (n, 3)),
               bg_color=np.random.uniform(0, 1, (n, 4)),
               size=64,
               fg_color=(0, 0, 0, 1))

window.attach(markers["transform"])
window.attach(markers["viewport"])
app.run()
Пример #4
0
# -----------------------------------------------------------------------------
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import numpy as np
from  glumpy import app
from glumpy.graphics.collections import MarkerCollection


window = app.Window(1024,1024, color=(1,1,1,1))

@window.event
def on_draw(dt):
    window.clear()
    markers.draw()
    markers['orientation'] += np.random.uniform(0.0,0.1,len(markers))
    del markers[0]
    if not len(markers):
        app.quit()

n = 256
markers = MarkerCollection(orientation='local')
markers.append(np.random.uniform(-1,1,(n,3)),
               bg_color = np.random.uniform(0,1,(n,4)),
               size = 64, fg_color=(0,0,0,1))


window.attach(markers["transform"])
window.attach(markers["viewport"])
app.run()
Пример #5
0
    v_fg_color    = fg_color;
    v_bg_color    = bg_color;
    v_orientation = vec2(cos(orientation), sin(orientation));
    gl_Position = <transform(position)>;
    float scale = (3.5 - length(gl_Position.xyz)/length(vec3(1.5)));
    v_fg_color.a = scale;
    v_bg_color.a = scale;
    scale=1;
    v_size       = scale * size;
    gl_PointSize = M_SQRT2 * size * scale + 2.0 * (linewidth + 1.5*antialias);
    <viewport.transform>;
}
"""

markers = MarkerCollection(marker="disc",
                           vertex=vertex,
                           viewport=viewport,
                           transform=transform)
# C, La, Lo = [], [], []
# with open(data.get("capitals.csv"), 'r') as file:
#     reader = csv.reader(file, delimiter=',')
#     next(reader, None) # skip the header
#     for row in reader:
#         capital = row[1]
#         latitude = np.pi/2 + float(row[2])*np.pi/180
#         longitude = np.pi  + float(row[3])*np.pi/180
#         C.append(capital)
#         La.append(latitude)
#         Lo.append(longitude)
# P = spheric_to_cartesian(Lo, La, radius*1.01)
# markers.append(P, bg_color = (1,1,1,1), fg_color=(.25,.25,.25,1), size = 10)