source pkgsNeeded.tcl

ui_init "t_warpanim.tcl"
SetFileTypes

PH "Image warping animation"

set srcimg [poImage NewImageFromFile "testIn/keksi$fInfo(suf)"]
$srcimg GetImageInfo w h a g
set dstimg [poImage NewImage $w $h $a $g]

set xsrc(0) 0.345
set xsrc(1) 0.550
set ysrc(0) 0.335
set ysrc(1) 0.280
set xdest(0) 0.335
set xdest(1) 0.600
set ydest(0) 0.410
set ydest(1) 0.350
set nkey 2
set nframes 50

for { set i 1 } { $i <= $nframes } { incr i } {
    set fname "testOut/warpanim.[format "%03d" $i]$fInfo(suf)"
    set msg   "$fname: Keyframe warping (2 keyframes) with little local effect"
    P $msg
    set xd(0) [expr (($xdest(0) - $xsrc(0))*$i/$nframes + $xsrc(0))]
    set xd(1) [expr (($xdest(1) - $xsrc(1))*$i/$nframes + $xsrc(1))]
    set yd(0) [expr (($ydest(0) - $ysrc(0))*$i/$nframes + $ysrc(0))]
    set yd(1) [expr (($ydest(1) - $ysrc(1))*$i/$nframes + $ysrc(1))]
    $dstimg WarpKeypoint $srcimg $nkey \
	    [ArrayToList xsrc 2] [ArrayToList ysrc 2] \
	    [ArrayToList xd 2]   [ArrayToList yd 2] 2 0.1
    poImgUtil SetDrawColorRGB 0 0 0
    $dstimg DrawRect 0 0 $w 5
    $dstimg DrawRect 0 [expr ($h-5)] $w $h
    $dstimg DrawRect 0 0 5 $h
    $dstimg DrawRect [expr ($w-5)] 0 $w $h
    $dstimg WriteSimple $fname $fInfo(fmt) $fInfo(vsn)
    ui_addimg $dstimg $msg
}

poImgUtil DeleteImg $srcimg

PS
P "End of test"

ui_show

if { [lindex $argv 0] eq "auto" } {
    ui_exit
    exit 0
}
