if key == '\033': sys.exit() # ----------------------------------------------------------------------------- if __name__ == '__main__': from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(600, 256) glut.glutCreateWindow("Antialiased lines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() for i in range(68): color = 0, 0, 0, 1 linewidth = .1 + i * .1 scale = 200 theta = -5 * np.pi / 180 translate = 32 + i * 8, 128 collection.append([(0.0, -0.5), (0.0, +0.5)], closed=False, linewidth=linewidth, color=color, scale=scale, rotate=theta, translate=translate) glut.glutMainLoop()
glut.glutInitWindowSize(512, 512) glut.glutCreateWindow( "Dashed & antialiased bezier curve [Arrow keys change offset]") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutSpecialFunc(on_special) atlas = DashAtlas() atlas['custom'] = (.1, .1), (1, 1) collection = PathCollection(atlas) # --------------------------------- points = np.array([[.1, .6], [.5, 1.], [.9, .6]]) vertices = curve3_bezier(*points) collection.append(vertices, color=(0.75, 0.75, 1.00, 1.00), linewidth=40, dash_pattern='densely dashed') # --------------------------------- vertices = curve3_bezier(*(points + [0, -0.3])) collection.append(vertices, color=(0.75, 0.75, 1.00, 1.0), linewidth=50, linecaps=('|', '|'), dash_pattern='custom', dash_caps=('|', '|')) glut.glutMainLoop()
if __name__ == '__main__': from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("OpenGL antialiased lines") glut.glutReshapeWindow(512, 512 + 32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) vertices = np.array([(+0.0, +0.5), (+0.0, -0.5)]) collection = PathCollection() for i in range(500): theta = i * (5.5 / 180.0 * np.pi) radius = 255 - i * 0.45 x = 256 + np.cos(theta) * radius y = 256 + np.sin(theta) * radius + 32 scale = 20 - 15 * i / float(500) collection.append(vertices, closed=False, translate=(x, y), scale=scale, rotate=theta + np.pi / 2) for i in range(0, 49): linewidth = (i + 1) / 10.0 collection.append([(20 + i * 10 + .315, 10), (20 + i * 10 + .315, 22)], linewidth=linewidth) glut.glutMainLoop()
from glagg import PathCollection from shapes import star, asterisk glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH) glut.glutInitWindowSize(512, 512) glut.glutCreateWindow("Dashed stars") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) t0, frames, t = 0, 0, 0 t0 = glut.glutGet(glut.GLUT_ELAPSED_TIME) collection = PathCollection() vertices = star(n=5) for i in range(2000): collection.append(vertices, closed=True, color=np.random.uniform(0, 1, 4), linewidth=np.random.uniform(1, 2), translate=np.random.uniform(0, 1, 2), scale=np.random.uniform(10, 15), rotate=np.random.uniform(0, 2 * np.pi), dash_pattern='dotted') positions = collection.translate.copy() glut.glutMainLoop()
glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) collection = PathCollection() def heart(): vertices = curve4_bezier( (0.0,-0.5), (0.75,+0.25), (.75,+1.0), (0.0,+0.5) ) n = len(vertices) V = np.zeros((2*n,2)) V[:n] = vertices V[n:] = vertices[::-1] V[n:,0] *=-1 V[n:,0] -= .0001 return V vertices = heart() for i in range(2000): color = np.random.uniform(0,1,4) linewidth = 1 translate = np.random.uniform(0,800,2) scale = 20 rotate = np.random.uniform(0,2*np.pi) collection.append( vertices, closed=True, color = color, linewidth = linewidth, translate = translate, scale = scale, rotate = rotate) glut.glutMainLoop()
glut.GLUT_DEPTH | glut.GLUT_STENCIL ) glut.glutInitWindowSize(800, 800) glut.glutCreateWindow("Clipping demo") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) collection = PathCollection() mask = PathCollection() size = 800 collection.clear() vertices = star(n=5) for i in range(2000): collection.append( vertices, closed=True, color = np.random.uniform(0,1,4), linewidth = np.random.uniform(1,2), translate = np.random.uniform(0,1,2), scale = np.random.uniform(10,15), rotate = np.random.uniform(0,2*np.pi)) positions = collection.translate.copy() mask.clear() mask.append( vertices, closed=True, color = (0,0,0,1), linewidth=100, translate=(size/2, size/2), scale=size * 0.4) glut.glutMainLoop()
def on_reshape(width, height): gl.glViewport(0, 0, width, height) # ------------------------------------- def on_keyboard(key, x, y): if key == '\033': sys.exit() # ----------------------------------------------------------------------------- if __name__ == '__main__': import sys import OpenGL.GLUT as glut from shapes import star, asterisk from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(800, 800) glut.glutCreateWindow("Error case 1") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() vertices = star(n=25) collection.append( vertices, closed=True, linewidth=15, color = (0,0,0,1), linejoin = 'miter', miter_limit=15.0, translate=(400,400), scale=300) glut.glutMainLoop()
# ----------------------------------------------------------------------------- if __name__ == "__main__": from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(600, 256) glut.glutCreateWindow("Antialiased lines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() for i in range(68): color = 0, 0, 0, 1 linewidth = 0.1 + i * 0.1 scale = 200 theta = -5 * np.pi / 180 translate = 32 + i * 8, 128 collection.append( [(0.0, -0.5), (0.0, +0.5)], closed=False, linewidth=linewidth, color=color, scale=scale, rotate=theta, translate=translate, ) glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(512, 512) glut.glutCreateWindow("Line joins") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutSpecialFunc(on_special) vertices = np.array( [(-0.50,-0.125), (-0.25,+0.125), (+0.00,-0.125), (+0.25,+0.125), (+0.50,-0.125) ] ) collection = PathCollection() collection.append(vertices, linewidth = 40, linejoin = 'miter', linecaps= ('<','>'), scale = 300, translate = (256,128) ) collection.append(vertices, linewidth = 40, linejoin = 'round', linecaps= ('(',')'), scale = 300, translate = (256,256) ) collection.append(vertices, linewidth = 40, linejoin = 'bevel', linecaps= ('=','='), scale = 300, translate = (256,384) ) glut.glutMainLoop()
# For OSX, see https://github.com/nanoant/osxglut # GLUT for Mac OS X fork with Core Profile and scroll wheel support try: from ctypes import c_float from OpenGL.GLUT.special import GLUTCallback glutScrollFunc = GLUTCallback( 'Scroll', (c_float,c_float), ('delta_x','delta_y'),) glutScrollFunc(on_scroll) except: if bool(glut.glutMouseWheelFunc): glut.glutMouseWheelFunc(on_wheel) collection = PathCollection() def dist(v0,v1): x0,y0 = v0 x1,y1 = v1 dx,dy = (x1-x0), (y1-y0) return dx*dx+dy*dy vertices = svg_open('data/tiger.svg') for V in vertices: closed = dist(V[0],V[-1]) < 1e-10 V = np.array(V) V[:,1] = -V[:,1] collection.append(V, closed=closed, linewidth=scale/4.0, translate=translate, scale=scale, dash_pattern = 'loosely dashed') glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from shapes import star, asterisk from glagg import PathCollection t0, frames, t = 0,0,0 t0 = glut.glutGet(glut.GLUT_ELAPSED_TIME) glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH) glut.glutInitWindowSize(512, 512) glut.glutCreateWindow("Antialiased thick polylines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) vertices = np.array( [(+0.0,+0.5), (+0.0,-0.5)] ) collection = PathCollection() for i in range(500): theta = i*(5.5/180.0*np.pi) radius = 255-i*0.45 x = 256 + np.cos(theta)*radius y = 256 + np.sin(theta)*radius scale = 20-15*i/float(500) collection.append(vertices, closed=False, scale = scale, rotate = theta + np.pi/2, translate = (x,y), dash_pattern = 'loosely dotted' ) glut.glutMainLoop()
'Scroll', (c_float, c_float), ('delta_x', 'delta_y'), ) glutScrollFunc(on_scroll) except: if bool(glut.glutMouseWheelFunc): glut.glutMouseWheelFunc(on_wheel) collection = PathCollection() def dist(v0, v1): x0, y0 = v0 x1, y1 = v1 dx, dy = (x1 - x0), (y1 - y0) return dx * dx + dy * dy vertices = svg_open('data/tiger.svg') for V in vertices: closed = dist(V[0], V[-1]) < 1e-10 V = np.array(V) V[:, 1] = -V[:, 1] collection.append(V, closed=closed, linewidth=scale / 4.0, translate=translate, scale=scale, dash_pattern='loosely dashed') glut.glutMainLoop()
# ------------------------------------- def on_keyboard(key, x, y): if key == '\033': sys.exit() if key == ' ': fbo.save( on_display, "gl-spiral.png") # ----------------------------------------------------------------------------- if __name__ == '__main__': from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("OpenGL antialiased spiral") glut.glutReshapeWindow(512, 512+32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() vertices=[] n = 2000 angles = np.linspace(0,18*2*np.pi, n) radii = np.linspace(1,228, n) for angle,radius in zip(angles,radii): x,y = radius*np.cos(angle), radius*np.sin(angle) vertices.append((x+256,y+256+32)) collection.append(vertices) glut.glutMainLoop()
glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) collection = PathCollection() mask = PathCollection() size = 800 collection.clear() vertices = star(n=5) for i in range(2000): collection.append(vertices, closed=True, color=np.random.uniform(0, 1, 4), linewidth=np.random.uniform(1, 2), translate=np.random.uniform(0, 1, 2), scale=np.random.uniform(10, 15), rotate=np.random.uniform(0, 2 * np.pi)) positions = collection.translate.copy() mask.clear() mask.append(vertices, closed=True, color=(0, 0, 0, 1), linewidth=100, translate=(size / 2, size / 2), scale=size * 0.4) glut.glutMainLoop()
import sys import OpenGL.GLUT as glut from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(1000, 800) glut.glutCreateWindow("Antialiased thick polylines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) V = np.array([[-.1, 0.], [.0, +1.], [+.1, 0.]]) xmin, xmax = V[:, 0].min(), V[:, 0].max() ymin, ymax = V[:, 1].min(), V[:, 1].max() V[:, 0] -= (xmax + xmin) / 2.0 V[:, 1] -= (ymax + ymin) / 2.0 collection = PathCollection() collection.append(V, closed=False, translate=(500, 400), scale=100, color=(0, 0, 0, 1), linewidth=50, antialias=1, linejoin='round', miter_limit=4.0, linecaps=('square', 'square')) glut.glutMainLoop()
from glagg import curve3_bezier, curve4_bezier from glagg import PathCollection from glagg import DashAtlas glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH) glut.glutInitWindowSize(512, 512) glut.glutCreateWindow("Dashed & antialiased bezier curve [Arrow keys change offset]") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutSpecialFunc(on_special) atlas = DashAtlas() atlas['custom'] = (.1,.1), (1,1) collection = PathCollection( atlas ) # --------------------------------- points = np.array([[.1, .6], [.5, 1.], [.9, .6]]) vertices = curve3_bezier(*points) collection.append(vertices, color=(0.75,0.75,1.00,1.00), linewidth=40, dash_pattern = 'densely dashed') # --------------------------------- vertices = curve3_bezier(*(points + [0, -0.3])) collection.append( vertices, color=(0.75,0.75,1.00,1.0), linewidth=50, linecaps = ('|','|'), dash_pattern = 'custom', dash_caps=('|','|') ) glut.glutMainLoop()
# ----------------------------------------------------------------------------- if __name__ == '__main__': from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("OpenGL antialiased lines") glut.glutReshapeWindow(512, 512+32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) vertices = np.array( [(+0.0,+0.5), (+0.0,-0.5)] ) collection = PathCollection() for i in range(500): theta = i*(5.5/180.0*np.pi) radius = 255-i*0.45 x = 256 + np.cos(theta)*radius y = 256 + np.sin(theta)*radius + 32 scale = 20-15*i/float(500) collection.append(vertices, closed=False, translate = (x,y), scale = scale, rotate = theta + np.pi/2) for i in range(0,49): linewidth = (i+1)/10.0 collection.append( [(20+i*10+.315,10),(20+i*10+.315,22)], linewidth=linewidth) glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from shapes import star, asterisk from glagg import PathCollection t0, frames, t = 0,0,0 t0 = glut.glutGet(glut.GLUT_ELAPSED_TIME) glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH) glut.glutCreateWindow("Antialiased thick polylines") glut.glutReshapeWindow(512, 512) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) vertices = np.array( [(+0.0,+0.5), (+0.0,-0.5)] ) collection = PathCollection() for i in range(500): theta = i*(5.5/180.0*np.pi) radius = 255-i*0.45 x = 256 + np.cos(theta)*radius y = 256 + np.sin(theta)*radius scale = 20-15*i/float(500) collection.append(vertices, closed=False, scale = scale, rotate = theta + np.pi/2, translate = (x,y), dash_pattern = 'loosely dotted' ) glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(1000, 800) glut.glutCreateWindow("Antialiased thick polylines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) V = np.array([[-.1, 0.], [ .0, +1.], [+.1, 0.]]) xmin,xmax = V[:,0].min(),V[:,0].max() ymin,ymax = V[:,1].min(),V[:,1].max() V[:,0] -= (xmax+xmin)/2.0 V[:,1] -= (ymax+ymin)/2.0 collection = PathCollection() collection.append(V, closed=False, translate = (500,400), scale = 100, color=(0,0,0,1), linewidth=50, antialias=1, linejoin='round', miter_limit=4.0, linecaps=('square','square')) glut.glutMainLoop()
import re import xml.dom import xml.dom.minidom from glagg import Path, PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("SVG Tiger") glut.glutReshapeWindow(512, 512 + 32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() def dist(v0, v1): x0, y0 = v0 x1, y1 = v1 dx, dy = (x1 - x0), (y1 - y0) return dx * dx + dy * dy vertices = svg_open('tiger.svg') for V in vertices: closed = dist(V[0], V[-1]) < 1e-10 V = np.array(V) V[:, 1] = -V[:, 1] V += (180, 380) collection.append(V, closed=closed, linewidth=.25) glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("Line joins") glut.glutReshapeWindow(512, 512) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutSpecialFunc(on_special) vertices = np.array( [(-0.50,-0.125), (-0.25,+0.125), (+0.00,-0.125), (+0.25,+0.125), (+0.50,-0.125) ] ) collection = PathCollection() collection.append(vertices, linewidth = 40, linejoin = 'miter', linecaps= ('<','>'), scale = 300, translate = (256,128) ) collection.append(vertices, linewidth = 40, linejoin = 'round', linecaps= ('(',')'), scale = 300, translate = (256,256) ) collection.append(vertices, linewidth = 40, linejoin = 'bevel', linecaps= ('=','='), scale = 300, translate = (256,384) ) glut.glutMainLoop()
glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("OpenGL antialiased stars") glut.glutReshapeWindow(512, 512 + 32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() s = star() radius = 255.0 theta, dtheta = 0, 5.5 / 180.0 * np.pi for i in range(500): theta += dtheta x = 256 + radius * np.cos(theta) y = 256 + 32 + radius * np.sin(theta) r = 10.1 - i * 0.02 radius -= 0.45 collection.append(s * r + (x, y), closed=True, linejoin='miter') for i in range(0, 39): linewidth = (i + 1) / 20.0 x = 20 + i * 12.5 - r y = 16 collection.append(s * 4 + (x, y), closed=True, linewidth=linewidth, linejoin='miter') glut.glutMainLoop()
if __name__ == '__main__': import sys import OpenGL.GLUT as glut from shapes import star, asterisk from glagg import PathCollection t0, frames, t = 0,0,0 t0 = glut.glutGet(glut.GLUT_ELAPSED_TIME) glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH) glut.glutInitWindowSize(800, 800) glut.glutCreateWindow("Asterisks") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutIdleFunc(on_idle) collection = PathCollection() vertices = asterisk(n=5) for i in range(2000): collection.append( vertices, closed=True, color = np.random.uniform(0,1,4), linewidth = np.random.uniform(1,2), translate = np.random.uniform(0,1,2), scale = np.random.uniform(10,15), rotate = np.random.uniform(0,2*np.pi)) positions = collection.translate.copy() glut.glutMainLoop()
collection = PathCollection() def heart(): vertices = curve4_bezier( (0.0,-0.5), (0.75,+0.25), (.75,+1.0), (0.0,+0.5) ) n = len(vertices) V = np.zeros((2*n,2)) V[:n] = vertices V[n:] = vertices[::-1] V[n:,0] *=-1 V[n:,0] -= .0001 return V vertices = heart() for i in range(2000): color = np.random.uniform(0,1,4) linewidth = 1 translate = np.random.uniform(0,1,2) scale = 20 rotate = np.random.uniform(0,2*np.pi) collection.append( vertices, closed=True, color = color, linewidth = linewidth, translate = translate, scale = scale, rotate = rotate) position = collection.translate.copy() glut.glutMainLoop()
from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutCreateWindow("OpenGL antialiased stars") glut.glutReshapeWindow(512, 512+32) glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) collection = PathCollection() s = star() radius = 255.0 theta, dtheta = 0, 5.5/180.0*np.pi for i in range(500): theta += dtheta x = 256+radius*np.cos(theta) y = 256+32+radius*np.sin(theta) r = 10.1-i*0.02 radius -= 0.45 collection.append( s*r + (x,y), closed=True, linejoin='miter') for i in range(0,39): linewidth = (i+1)/20.0 x = 20+i*12.5 - r y = 16 collection.append( s*4 + (x,y), closed=True, linewidth=linewidth, linejoin='miter') glut.glutMainLoop()
elif key == glut.GLUT_KEY_RIGHT: collection.dash_phase += 0.05 glut.glutPostRedisplay() # ----------------------------------------------------------------------------- if __name__ == '__main__': import sys import OpenGL.GLUT as glut from shapes import star from glagg import PathCollection glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB) glut.glutInitWindowSize(800, 800) glut.glutCreateWindow("Error case 1") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_keyboard) glut.glutSpecialFunc(on_special) collection = PathCollection() vertices = [] for theta in np.linspace(0,2*np.pi,100,endpoint=False): x,y = 0.5*np.cos(theta), 0.5*np.sin(theta) vertices.append( (x,y) ) #vertices = star(n=5) collection.append( vertices, closed=True, linewidth=25, color = (0,0,0,1), dash_pattern = 'dashed', translate=(400,400), scale=400) glut.glutMainLoop()