Esempio n. 1
0
    if key == ' ': fbo.save(on_display, "gl-circles.png")


# -----------------------------------------------------------------------------
if __name__ == '__main__':
    from glagg import CircleCollection

    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB)
    glut.glutCreateWindow("OpenGL antialiased circles")
    glut.glutReshapeWindow(512, 512 + 32)
    glut.glutDisplayFunc(on_display)
    glut.glutReshapeFunc(on_reshape)
    glut.glutKeyboardFunc(on_keyboard)

    collection = CircleCollection()
    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(center=(x, y), radius=r)

    for i in range(0, 39):
        linewidth = (i + 1) / 10.0
        x = 20 + i * 12.5 - r
        y = 16
        collection.append(center=(x, y), radius=4, linewidth=linewidth)
Esempio n. 2
0
    circles.append( center = p3, radius = 4, fg_color=(0.0,0.0,1.0,1.0) )


# -----------------------------------------------------------------------------
if __name__ == '__main__':
    import sys
    import OpenGL.GLUT as glut

    from glagg import curve3_bezier, curve4_bezier
    from glagg import PathCollection, CircleCollection

    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
    glut.glutInitWindowSize(800, 800)
    glut.glutCreateWindow("Dynamic cubic Bézier curve [drag handles with mouse]")
    glut.glutDisplayFunc(on_display)
    glut.glutReshapeFunc(on_reshape)
    glut.glutKeyboardFunc(on_keyboard)
    glut.glutMouseFunc(on_mouse)
    glut.glutMotionFunc(on_motion)
    glut.glutPassiveMotionFunc(on_passive_motion)

    paths = PathCollection()
    circles = CircleCollection()
    drag,index = False, -1
    points = np.array( [ (100.,400.), (400.,700.),
                         (500.,100.), (700.,400.) ] )
    add_bezier(*points)

    glut.glutMainLoop()