{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Animation {#animation_example}\n\nThis example demonstrates how to create a simple animation. A timer is\nused to move a sphere across a scene.\n\nInspired by [VTK Animation\nExamples](https://examples.vtk.org/site/Python/Utilities/Animation/).\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyvista as pv\n\nsphere = pv.Sphere()\n\npl = pv.Plotter()\nactor = pl.add_mesh(sphere)\n\n\ndef callback(step):\n actor.position = [step / 100.0, step / 100.0, 0]\n\n\npl.add_timer_event(max_steps=200, duration=500, callback=callback)\n\ncpos = [(0.0, 0.0, 10.0), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)]\npl.show(cpos=cpos)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }