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
def add_bezier(p0,p1,p2,p3): vertices = curve4_bezier(p0, p1, p2, p3) paths.append(vertices, color=(0.75,0.75,0.75,1.0), linewidth=12.0, linecaps=('<','>'), dash_pattern = 'densely dashed', dash_caps=('<','>') ) paths.append((p0,p1), color=(0.0,0.0,1.0,1.0), dash_pattern='solid') paths.append((p2,p3), color=(0.0,0.0,1.0,1.0), dash_pattern='solid') circles.append( center = p0, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p1, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p2, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p3, radius = 4, fg_color=(0.0,0.0,1.0,1.0) )
def add_bezier(p0,p1,p2,p3): vertices = curve4_bezier(p0, p1, p2, p3) paths.append(vertices, color=(0.75,0.75,0.75,1.0), linewidth=24.0, linecaps=('<','>'), dash_pattern = 'densely dashed', dash_caps=('<','>') ) paths.append((p0,p1), color=(0.0,0.0,1.0,1.0), dash_pattern='solid') paths.append((p2,p3), color=(0.0,0.0,1.0,1.0), dash_pattern='solid') circles.append( center = p0, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p1, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p2, radius = 4, fg_color=(0.0,0.0,1.0,1.0) ) circles.append( center = p3, radius = 4, fg_color=(0.0,0.0,1.0,1.0) )
import OpenGL.GLUT as glut from glagg import curve3_bezier, curve4_bezier, 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("Antialiased thick polylines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_key) glut.glutIdleFunc(on_idle) collection = PathCollection() for i in range(2000): p0,p1,p2,p3 = np.random.uniform(-1,1,(4,2)) vertices = curve4_bezier(p0,p1,p2,p3) color = np.random.uniform(0,1,4) linewidth = np.random.uniform(2,3) translate = np.random.uniform(0,1,2) scale = np.random.uniform(20,45) rotate = np.random.uniform(0,2*np.pi) collection.append( vertices, color = color, linewidth = linewidth, translate = translate, scale=scale, rotate = rotate ) positions = collection.translate.copy() glut.glutMainLoop()
width = 175 p0,p1,p2 = np.array([(150.,100.), (300.,700.), (450,100)]) p0,p1,p2 = np.array([p0,p1,p2]) V = curve3_bezier( p0, p1, p2 ) V0,V1 = curve_thicken(V, width, unfold=False) draw_curve(V,V0,V1,(0,50)) plt.text(300,50,"Folded",ha='center',va='center',fontsize=32) V0,V1 = curve_thicken(V, width, unfold=True) draw_curve(V,V0,V1,(600,50)) plt.text(900,50,"Unfolded",ha='center',va='center',fontsize=32) #p0, p1, p2, p3 = (100.,100.), (450.,500.), (150.,500.),(500,100) p0, p1, p2, p3 = (100.,300.), (200.,600.), (400,0.), (500.,300.) #p0, p1, p2, p3 = (200.,150.), (-200.,450.), (800,450.), (400.,150.) p0,p1,p2,p3 = np.array([p0,p1,p2,p3]) V = curve4_bezier( p0, p1, p2, p3) V0,V1 = curve_thicken(V, width, unfold=False) draw_curve(V,V0,V1,(0,500)) #plt.text(300,550,"Folded",ha='center',va='center',fontsize=48) V0,V1 = curve_thicken(V, width, unfold=True) draw_curve(V,V0,V1,(600,500)) #plt.text(900,550,"Unfolded",ha='center',va='center',fontsize=48) plt.savefig("folding.pdf") plt.show()
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("Antialiased thick polylines") glut.glutDisplayFunc(on_display) glut.glutReshapeFunc(on_reshape) glut.glutKeyboardFunc(on_key) glut.glutIdleFunc(on_idle) collection = PathCollection() for i in range(2000): p0, p1, p2, p3 = np.random.uniform(-1, 1, (4, 2)) vertices = curve4_bezier(p0, p1, p2, p3) color = np.random.uniform(0, 1, 4) linewidth = np.random.uniform(2, 3) translate = np.random.uniform(0, 1, 2) scale = np.random.uniform(20, 45) rotate = np.random.uniform(0, 2 * np.pi) collection.append(vertices, color=color, linewidth=linewidth, translate=translate, scale=scale, rotate=rotate) positions = collection.translate.copy() glut.glutMainLoop()