# Usage: # streaming_pixels.tk set width [lindex $argv 0] set height [lindex $argv 1] set pixels_per_repaint [lindex $argv 2] set magnify [lindex $argv 3] # start with blank data set data [list] for {set x 0} {$x < $width * $magnify} {incr x} { set col [list] for {set y 0} {$y < $height * $magnify} {incr y} { lappend col "#000000" } lappend data $col } set image [image create photo] $image put $data label .l -image $image pack .l proc update_pixels {} { after 100 { for {set count 0} {$count < $pixels_per_repaint} {incr count} { gets stdin tuple set x0 [lindex $tuple 0] set y0 [lindex $tuple 1] set r [lindex $tuple 2] set g [lindex $tuple 3] set b [lindex $tuple 4] for {set x1 0} {$x1 < $magnify} {incr x1} { for {set y1 0} {$y1 < $magnify} {incr y1} { set x [expr $x0*$magnify+$x1] set y [expr $y0*$magnify+$y1] set col [lindex $data $x] set formatted [format "#%02x%02x%02x" $r $g $b] set col [lreplace $col $y $y $formatted] set data [lreplace $data $x $x $col] } } } $image put $data update_pixels } } update_pixels