window.clear() triangles.draw() paths.draw() @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) @window.event def on_key_press(key, modifiers): if key == app.window.key.SPACE: transform.reset() transform = PanZoom(OrthographicProjection(Position())) triangles = TriangleCollection("agg", transform=transform, color='shared') paths = PathCollection("agg", transform=transform, color='shared') paths["linewidth"] = 10 P = star() I = triangulate(P) n = 64 for i in range(n): c = i/float(n) d = i x,y = np.random.uniform(0,800,2) s = 25 triangles.append(P*s+(x,y,d), I, color=(0,0,0,.5)) paths.append(P*s+(x,y,(d-1)), closed=True, color=(0,0,0,1))
gl.glEnable(gl.GL_BLEND) gl.glDepthMask(gl.GL_FALSE) outlines.draw() gl.glDepthMask(gl.GL_TRUE) @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(0.75) transform = Trackball(Position()) cells = TriangleCollection("raw", transform=transform, color="shared") outlines = PathCollection("raw", transform=transform, color="shared") # Random points n = 2000 points = np.random.normal(size=(n, 3)) points /= np.linalg.norm(points, axis=1)[:, np.newaxis] # Voronoi cells sv = SphericalVoronoi(points, 2, (0, 0, 0)) sv.sort_vertices_of_regions() for region in sv.regions: z = np.random.uniform(0, 1) V = (1.0 + 0.1 * z) * sv.vertices[region]
gl.glEnable(gl.GL_BLEND) gl.glDepthMask(gl.GL_FALSE) outlines.draw() gl.glDepthMask(gl.GL_TRUE) @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) gl.glPolygonOffset(1, 1) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(0.75) transform = Trackball(Position()) cells = TriangleCollection("raw", transform=transform, color='shared') outlines = PathCollection("raw", transform=transform, color='shared') # Random points n = 2000 points = np.random.normal(size=(n, 3)) points /= np.linalg.norm(points, axis=1)[:, np.newaxis] # Voronoi cells sv = SphericalVoronoi(points, 2, (0, 0, 0)) sv.sort_vertices_of_regions() for region in sv.regions: z = np.random.uniform(0, 1) V = (1.0 + 0.1 * z) * sv.vertices[region]