Re: tcl/tk manca winfo?
> $ man winfo
> winfo(3tk) Tk Built-In Commands
Tutti i comandi tcl/tk sono del linguaggio tcl (e del toolkit tk che
aggiunge comandi al linguaggio).
Il capitolo "3tk" del manuale winfo indica quello.
La shell tk si chiama wish (windowing shell). Si puo` usare
interattivamente o per eseguire script, come tutti gli altri linguaggi
interpretati.
Allego un mio programmino della palla che rimbalza. Amo tcl/tk, mi spiace
che sia passato di moda.
/alessandro
#!/usr/bin/wish
set w 240; set h 320
wm geometry . ${w}x${h}
wm overrideredirect . true
pack [canvas .c -width $w -height $h]
set maxx [expr $w-10]
set maxy [expr $h-10]
set I [.c create oval 0 0 10 10 -fill red]
# parameters
set sx 100.0; set sy 0.0;
set ela 0.9
set acc 1000.0
set attr 4.0
set x 0.0
set y 0.0
#speed x, speed x increment
set prevt [clock clicks -milliseconds]
update
# press
bind .c <1> {
set sx [expr $sx + $attr * (%x - $x +5)]
set sy [expr $sy + $attr * (%y - $y +5)]
}
# calc
while 1 {
set t [clock clicks -milliseconds]
set deltat [expr ($t-$prevt)/1000.0]
# horizontal
set x [expr $x + $sx*$deltat]
if {$x > $maxx} {
set x [expr 2*$maxx - $x]
set sx [expr -$ela*$sx]
set sy [expr $ela*$sy]
}
if {$x < 0} {
set x [expr -$x]
set sx [expr -$ela*$sx]
set sy [expr $ela*$sy]
}
# vertical
if $y!=$maxy {set sy [expr $sy+$acc*$deltat]}
set y [expr $y + $sy*$deltat]
if {$y > $maxy} {
set y [expr 2*$maxy - $y]
set sx [expr $ela*$sx]
if $sy>$acc*$deltat {
set sy [expr -$ela*$sy]
} else {
set sy 0.0; set y $maxy
}
}
if {$y < 0} {
set y [expr -$y]
set sx [expr $ela*$sx]
set sy [expr -$ela*$sy]
}
# puts "($deltat) $x $sx $y $sy"
.c coords $I $x $y [expr $x+10] [expr $y+10]
update
after 10
set prevt $t
}
Reply to: