-
Notifications
You must be signed in to change notification settings - Fork 0
/
trajectory_movie.tcl
61 lines (56 loc) · 1.64 KB
/
trajectory_movie.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
proc take_picture {args} {
global take_picture
# when called with no parameter, render the image
if {$args == {}} {
set f [format $take_picture(format) $take_picture(frame)]
# take 1 out of every modulo images
if { [expr $take_picture(frame) % $take_picture(modulo)] == 0 } {
render $take_picture(method) $f
# call any unix command, if specified
if { $take_picture(exec) != {} } {
set f [format $take_picture(exec) $f $f $f $f $f $f $f $f $f $f]
eval "exec $f"
}
}
# increase the count by one
incr take_picture(frame)
return
}
lassign $args arg1 arg2
# reset the options to their initial stat
# (remember to delete the files yourself
if {$arg1 == "reset"} {
set take_picture(frame) 0
set take_picture(format) "./animate.%04d.rgb"
set take_picture(method) snapshot
set take_picture(modulo) 1
set take_picture(exec) {}
return
}
# set one of the parameters
if [info exists take_picture($arg1)] {
if { [llength $args] == 1} {
return "$arg1 is $take_picture($arg1)"
}
set take_picture($arg1) $arg2
return
}
# otherwise, there was an error
error {take_picture: [ | reset | frame | format | \
method | modulo ]}
}
# to complete the initialization, this must be the first function
# called. Do so automatically.
take_picture reset
proc make_trajectory_movie_files {} {
set num [molinfo top get numframes]
# loop through the frames
for {set i 0} {$i < $num} {incr i} {
# go to the given frame
animate goto $i
# force display update
display update
# take the picture
take_picture
}
}