next up previous contents index
Next: Changing the color scale Up: VMD Script Commands for Previous: VMD Script Commands for

Adjusting the degree of transparency

      To change an object's transparency value from the default of .3 to a smaller value of .1, one would type the following Tcl script into the console, or write it to a text file and source it (see Using text commands

proc change_transparency {new_alpha} {
        # This will always get the correct colors even if VMD
        # gains new definitions in the future
        set color_start [colorinfo num]
        set color_end [expr $color_start * 2]
        # Go through the list of colors (by index) and 
        # change their transp. value
        for {set color $color_start} {$color < $color_end} {incr color} {
                color change alpha $color $new_alpha
        }
}

# to use:
change_transparency .1
You can even make a new popup window to do this:   
user add menu Transp
for {set i 0} {$i < 10} {incr i} {
   set f [expr $i / 10.0]
   user add subitem Transp $f "change_transparency $f"
}



Justin Gullingsrud
Tue Apr 6 09:22:39 CDT 1999