#!/usr/bin/wish wm title . $argv0 frame .b pack .b -side top -fill x -pady 2m label .b.l1 -text "File:" -width 5 -anchor c entry .b.f -width 20 -textvariable f .b.f insert 0 [lindex $argv 0] label .b.l2 -text "Size:" -width 5 -anchor c entry .b.hs -width 4 -text 240 -textvariable hs .b.hs insert 0 [lindex $argv 1] label .b.l3 -text "x" -width 1 -anchor c entry .b.vs -width 4 -textvariable vs .b.vs insert 0 [lindex $argv 2] button .b.d -text Draw -command "cbox \$f \$hs \$vs" button .b.q -text Quit -command "destroy ." pack .b.l1 .b.f .b.l2 .b.hs .b.l3 .b.vs .b.d .b.q -side left -expand 1 proc cbox {f hs vs} { destroy .c if {$hs>0 && $vs>0} then { pack [canvas .c -width [expr {$hs+2}] -height [expr {$vs+2}]] jplot .c $f $hs $vs } } proc jplot {w f hs vs} { set f [open $f] for {set j 3} {$j<$vs+3} {incr j} { for {set i 3} {$i<$hs+3} {incr i} { if {![eof $f]} { set jcolor [read $f 6] set x0 $i set y0 $j set x1 $i set y1 [expr {$j+1}] $w create line $x0 $y0 $x1 $y1 -width 1 -fill #$jcolor set jcolor [read $f 1] } } $w create line 2 2 [expr {$hs+3}] 2 -width 1 -fill black $w create line 2 [expr {$vs+3}] [expr {$hs+3}] [expr {$vs+3}] -width 1 -fill black $w create line 2 2 2 [expr {$vs+3}] -width 1 -fill black $w create line [expr {$hs+3}] 2 [expr {$hs+3}] [expr {$vs+3}] -width 1 -fill black } } cbox [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]