next up previous contents index
Next: Drawing a graph Up: User-Defined Graphics Previous: Introduction   Contents   Index

Tutorials and Examples

We'll start with some basic examples. Load VMD and enter:

  draw cylinder {0 0 0} {5 0 0} radius 0.2
VMD will print:
  Info) Loading new molecule ...
because of the way graphics are implemented (don't worry about the details yet) and draw a blue cylinder on the screen.

Now change the color to red and draw two more cylinders:

  draw color red
  draw cylinder {4 1 0} {5 0 0} radius 0.1
  draw cylinder {4 -1 0} {5 0 0} radius 0.1
You might want to reset the view. Since the original scene had no data, a default size was chosen. Now that there is data, a reset view will center the graphics just as if it was a regular molecule (in fact, the implementation is a molecule with no atoms and only graphics). You now have a simple arrow. Let's make a nicer looking one now. First, remove all the graphics:
  draw delete all
and make a cylinder with a cone on the end
  draw cylinder {0 0 0} {4 0 0} radius 0.1
  draw cone {4 0 0} {5 0 0} radius 0.15
Note that the widest part of the cone is at the first point. As long as we're at it, let's add some text to the end of the arrow in green
  draw color green
  draw text {5 0 0} "This way"
Cool, eh? Of course, more things are available than a cylinder, cone, and text. How about a sphere?
  draw sphere {0 0 0} radius 0.3
  draw sphere {0 2 0} radius 0.2
The color of the spheres is green because that was the previously assigned color. The color doesn't change until explicitly specified with the color option. The default color is blue.

And some lines, first, a dotted line connecting the spheres

  draw line {0 0 0} {0 2 0} style dashed
then a solid one from the second sphere to the end of the arrow
  draw line {0 2 0} {5 0 0}

Now, reset the view and move things around a bit. You may be surprised to see the lines appear and disappear. This is because the lines have a "material property"; which means they are affected by the lights. For some things, this may be useful, but usually if you want to draw lines, you'll need to turn materials off.

  draw materials off



Subsections
next up previous contents index
Next: Drawing a graph Up: User-Defined Graphics Previous: Introduction   Contents   Index
vmd@ks.uiuc.edu