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