Exemplo n.º 1
0
 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
Exemplo n.º 2
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=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) )
Exemplo n.º 3
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()