return to first page linux journal archive
keywordscontents

Listing 5. Stage 4 in Tcl/Tk, out.tcl

canvas .p -width  210  -height  210
.p create line 5 105 205 105
.p create line 105 5 105 205
.p create text 180 90 -text "x"
.p create text 120 10 -text "x'"
pack .p
proc draw { } {
if { ([gets stdin line] >= 0) && \
([scan $line "%f %f" x y] >= 2) } {
set x [expr 25 * $x + 105]
set y [expr -12.5 * $y + 105]
.p create oval $x $y $x $y
after 1 { draw }
}
}
after 0 { draw }