Posted to tcl by egavilan at Fri Apr 04 23:27:20 GMT 2008view pretty

This version copies the next index over the previous.

image source at http://www.eats-edu.com.ar/sva/modulo_1_archivos/4-Stroke-Engine.gif


if {![file exists [set imgfile [lindex $argv 0]]]} {
        print "Uso: $argv0 filename.gif"
        exit
}

proc animate {img nimg ms} {
        scan [$nimg cget -format] "GIF -index %d" index

        puts $index
        incr index
        if [catch {
                $nimg configure -format "GIF -index $index"
                }] {
            $nimg configure -format "GIF -index 0"
        }
        $img copy $nimg
        after $ms [info level 0]
}

set img [image create photo -file $imgfile -format "GIF -index 0"]
set nimg [image create photo -file $imgfile -format "GIF -index 1"]

pack [label .l -image $img -padx 20 -pady 20 -bg white] -side left

after 2000 animate $img $nimg 20