http://qs321.pair.com?node_id=708626


in reply to Pixel-based Plotting in Perl?

I recall doing the same thing as you: drawing, say, a bunch of diagonal lines on a screen using BASIC, and people coming up to me and going, "Whoa! What's that?" But that was in 1978 or so. :) These days, most people don't plot stuff like that on the console - although you still can, if you want to, at least in Linux (that's what the 'svga' library is for.) Assuming that you are running Linux, and want to do this with Perl, you could use Linux::Svgalib:

# From the module docs use Linux::Svgalib; my $svga = Linux::Svgalib->new(); $svga->init(); $svga->setmode(G640x480x16); # Set the color for the subsequent ops $svga->setcolor($color); # Place a pixel $svga->drawpixel($x, $y); # Draw a line $svga->drawline($x1, $y1, $x2, $y2); # ...and so on; see the other methods in the documentation $svga->setmode(TEXT);

This may be as close as you'll get to the old BASIC experience. :)

Update: Linux::Svgalib doesn't compile on my system (an error in the XS portion, which I'm too lazy to troubleshoot); however, vga seems to compile just fine, and appears (per the docs) to handle the same functions.


-- 
Human history becomes more and more a race between education and catastrophe. -- HG Wells

Replies are listed 'Best First'.
Re^2: Pixel-based Plotting in Perl?
by pat_mc (Pilgrim) on Sep 04, 2008 at 22:01 UTC
    oko1 -

    Thanks for your input ... and the shared bit of history which sounds similar to what I recall (even if my memory only takes me back as far as the late 80s ;-).
    Must try the library you suggest on my Linux machine. From the code snippets you provide I suspect this may be close to what I was looking for.
    Thanks again!

    Cheers -

    Pat