1 # vim: foldmarker=<<<,>>> foldmethod=marker
3 class tlc
::Interpolate {
18 method over_time
{seconds a_cb
}
35 body tlc
::Interpolate::constructor {args
} { #<<<1
40 body tlc
::Interpolate::destructor {} { #<<<1
42 after cancel
$afterid; set afterid
""
47 body tlc
::Interpolate::over_time {seconds a_cb
} { #<<<1
49 after cancel
$afterid; set afterid
""
50 set start
[clock clicks
-milliseconds]
51 set duration
[expr {int
($seconds * 1000)}]
52 set delta
[expr {abs
($from - $to)}]
53 set afterid
[after $interval [code
$this fire_cb
]]
57 body tlc
::Interpolate::fire_cb {} { #<<<1
58 after cancel
$afterid; set afterid
""
59 set elapsed
[expr {[clock clicks
-milliseconds] - $start}]
60 if {$elapsed < $duration} {
61 set afterid
[after $interval [code
$this fire_cb
]]
63 set x
[expr {$delta * (double
($elapsed) / $duration) + $from}]
65 set x
[expr {$from - $delta * (double
($elapsed) / $duration)}]
80 body tlc
::Interpolate::reverse {} { #<<<1
81 set dir
[expr {!$dir}]
82 set elapsed
[expr {[clock clicks
-milliseconds] - $start}]
84 [clock clicks
-milliseconds] -
85 ($duration - $elapsed)
94 body tlc
::Interpolate::get_dir {} { #<<<1