Graphics

Draw graphics primitives to the render window. This module is pretty useless in vmd-python without EGL support.

Graphics primitives

Here are all of the simple shapes you can draw:

cone Draws a cone.
cylinder Draws a cylinder
line Draw a line between the given vertices
point Draw a point at the given vertex
sphere Draws a sphere
text Draw text
triangle Draws a triangle
trinorm Draws a triangle with given vertices and vertex normals

Manipulating graphics primitives

listall List all drawn graphics objects on a given molecule
replace Delete a graphics object and have the next element replace this one.
delete Deletes a specified graphics object, or all graphics at a given molid
info Describe a graphics object with given index

Changing the style of graphics

VMD draws graphics in a “stack” of commands that are applied in order. Instead of setting the material or color for individual graphics primitives, the color or material is defined as a command put on the stack, then all subsequent primitives will be drawn with that style until a new color or material is set.

color Set color for subsequent graphics primitives in this molecule.
material Set material for all graphics in this molecule
materials Turns materials on or off for subsequent graphics primitives.

The following code will draw a red cylinder, then a blue sphere:

from vmd import molecule, graphics

drawmol = molecule.new(name="Drawings")
graphics.color(drawmol, 1)
cylinder_id = graphics.cylinder(drawmol, (0,0,0), (0,1,0), filled=True)
graphics.color(drawmol, 0)
sphere_id = graphics.sphere(drawmol, (0,0,0), radius=0.3)