Skip to main content
`Ctrl`+`K`

Note

Go to the end to download the full example code.

# Draw a Sphere

This example demonstrates how to create a sphere.

    import sys

    from vispy import scene
    from vispy.visuals.transforms import STTransform

    canvas = scene.SceneCanvas(keys='interactive', bgcolor='white',
                               size=(800, 600), show=True)

    view = canvas.central_widget.add_view()
    view.camera = 'arcball'

    sphere1 = scene.visuals.Sphere(radius=1, method='latitude', parent=view.scene,
                                   edge_color='black')

    sphere2 = scene.visuals.Sphere(radius=1, method='ico', parent=view.scene,
                                   edge_color='black')

    sphere3 = scene.visuals.Sphere(radius=1, rows=10, cols=10, depth=10,
                                   method='cube', parent=view.scene,
                                   edge_color='black')

    sphere1.transform = STTransform(translate=[-2.5, 0, 0])
    sphere3.transform = STTransform(translate=[2.5, 0, 0])

    view.camera.set_range(x=[-3, 3])

    if __name__ == '__main__' and sys.flags.interactive == 0:
        canvas.app.run()

Total running time of the script: (0 minutes 0.541 seconds)

Gallery generated by Sphinx-Gallery