[ulis], 2004-03-13. A LCD hexa panel. [http://perso.wanadoo.fr/maurice.ulis/tcl/LCDhexapanel.png] ---- '''Digits stuff''' # -------- # digits stuff # -------- # font description array set hexdigits \ { " " {0 0 0 0 0 0 0} "0" {1 1 1 0 1 1 1} "1" {0 0 1 0 0 1 0} "2" {1 0 1 1 1 0 1} "3" {1 0 1 1 0 1 1} "4" {0 1 1 1 0 1 0} "5" {1 1 0 1 0 1 1} "6" {1 1 0 1 1 1 1} "7" {1 0 1 0 0 1 0} "8" {1 1 1 1 1 1 1} "9" {1 1 1 1 0 1 1} "A" {1 1 1 1 1 1 0} "B" {0 1 0 1 1 1 1} "C" {1 1 0 0 1 0 1} "D" {0 0 1 1 1 1 1} "E" {1 1 0 1 1 0 1} "F" {1 1 0 1 1 0 0} } # add a digit to the panel proc add:digit {w x y tag} \ { set dx $::(dx) set dy $::(dy) create:segment $w $tag:0 $x $y 0 0 $dx 0 create:segment $w $tag:1 $x $y 0 0 0 $dy create:segment $w $tag:2 $x $y $dx 0 $dx $dy incr y $dy create:segment $w $tag:3 $x $y 0 0 $dx 0 create:segment $w $tag:4 $x $y 0 0 0 $dy create:segment $w $tag:5 $x $y $dx 0 $dx $dy incr y $dy create:segment $w $tag:6 $x $y 0 0 $dx 0 } # add a segment to a digit proc create:segment {w tag x y dx0 dy0 dx1 dy1} \ { $w create line \ [expr {$x + $dx0}] [expr {$y + $dy0}] \ [expr {$x + $dx1}] [expr {$y + $dy1}] \ -tags [list $tag $tag] \ -fill $::(color) -width $::(width) } # set a digit proc set:digit {w tag digit} \ { set n 0 foreach segment $::hexdigits($digit) \ { $w itemconfig $tag:$n -state [expr {$segment ? "normal" : "hidden"}] incr n } } ---- '''Demo''' # -------- # demo # -------- wm title . "LCD hexa panel" # parms array set {} \ { dx 15 dy 15 color red width 3 } # canvas pack [canvas .c] # digits set n 0 set x 5 foreach digit [lsort [array names hexdigits]] \ { add:digit .c $x 5 d$n set:digit .c d$n $digit incr n incr x 20 } foreach {- - width height} [.c bbox all] break .c config -width $width -height $height ---- [Category Example]