Created
January 15, 2018 17:28
-
-
Save bjornblissing/8001771eb71aa64565aa07876f76bf85 to your computer and use it in GitHub Desktop.
PyMol script: 360 degree rotation animation in GIF format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load PyMol model, file extension will be autodetected | |
load testmodel | |
# Start of python script | |
python | |
import imageio | |
# Number of degrees to rotate each frame | |
step = 10 | |
# Vector to hold images | |
images = [] | |
for a in range(0,360,step): | |
cmd.rotate("y", float(step)) # Rotate around Y-axis | |
cmd.ray(256,256) # Raytrace 256x256 image | |
filename = "file"+str(a)+".png" | |
cmd.png(filename) | |
images.append(imageio.imread(filename)) | |
# Create gif animation from images | |
imageio.mimsave('animation.gif', images) | |
# End of python script | |
python end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: The
imageio
package needs to be installed to run this.