Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Pixel-based Plotting in Perl?

by oko1 (Deacon)
on Sep 02, 2008 at 22:26 UTC ( #708626=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://708626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2022-05-20 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?