next up previous contents index
Next: 6.4.2 Changing the color Up: 6.4 VMD Script Commands Previous: 6.4 VMD Script Commands

6.4.1 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 into the script console.

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"
}



Sergei Izrailev
Fri Jul 25 17:07:27 CDT 1997