I made a quick little tcl/tk script to read pixels from stdin, and then display them on the screen. You run it like this:
wish streaming_pixels.tk <width> <height> <pixels-per-repaint> <magnification>
Then you send lines of the form "x y r g b" into stdin. For example, here's a perl script that generates an animation of a 20x20 grid of pixels with a red/green gradient, with the blue component increasing slowly:
for $z (0..9) {
for $y (0..19) {
for $x (0..19) {
print "$x $y ".($x*13)." ".($y*13)." ".($z*26)."\n";
}
}
}
If you pipe this into the streaming_pixels script, with a magnification of 4, you get this:
perl genpixels.pl | wish streaming_pixels.tk 20 20 400 4
There are two advantage to this script as opposed to the numerous others that convert text formats into images. First, the pixels don't have to be in strict top-down left-right order -- you can send in pixels for any part of the image at any time. Second, you can overwrite pixel values that have already been input, so the script can handle animations.
I don't know enough tcl to make the script process all the pixels that are available before repainting, so instead you have to explicitly specify how many pixels it should read in between repaints. There's a 100ms wait between repaints, so don't set this number too low or you'll die of old age before it finishes the first frame. I also don't know enough to make it handle end-of-input correctly, so instead you just have to ignore the error message at the end.
Posted on August 9, 2004 06:50 PM
More programming articles
Though I realize it's just a linear gradient, those really remind me of the old sineplasmas you wrote.
Posted by: Jesse at August 9, 2004 07:47 PMYep, I've always been a pushover for high-saturation images produced with minimal code.
That and the color orange :)
Posted by: Kim at August 13, 2004 10:12 AMIf you're interested in this sort of image manipulation you'd do well to take a close look at Pancito:
http://www.acooke.org/jara/pancito/intro.html