Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

shading boxes using PostScript::Simple

by spider122 (Initiate)
on Oct 07, 2011 at 02:16 UTC ( #930094=perlquestion: print w/ replies, xml ) Need Help??
spider122 has asked for the wisdom of the Perl Monks concerning the following question:

I'm using PostScript::Simple and I need to create a box that is shaded grey. The only option I see is "filled" which if set to 1 fills the box black. Is there any way to fill it grey? I tried using $p->setcolour, but that didn't seem to work either. Thanks.

Comment on shading boxes using PostScript::Simple
Re: shading boxes using PostScript::Simple
by adds_work (Initiate) on Oct 07, 2011 at 05:32 UTC
    use PostScript::Simple; # create a new PostScript object $p = new PostScript::Simple(papersize => "A4", colour => 1, eps => 0, units => "in"); # create a new page $p->newpage; #select a shade of grey $p->setcolour("grey20"); # draw a filled square with lower left point at (20,20) $p->polygon( {offset => [10,10], filled => 1}, 10,10, 10,20, 20,20, 20,10, 10,10); $p->output("file.ps");

      adds_work:

      Hmmm...I tried your example, but when using ghostview to see it, I didn't see the rectangle. I added the "filled=>1" from your example to the example from the PostScript::Simple documentation, and it worked just fine. It seems to me that your units are off and that you're drawing the (huge) rectangle off the page.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Thanks for the help. The example shown doesn't show the box on the screen, but I was able to get it to work. I need a box with a black border and filled grey. I assume I should just draw it twice and set the color differently in between:
        use PostScript::Simple; # create a new PostScript object $p = new PostScript::Simple(papersize => "A4", colour => 1, eps => 0, units => "pt"); # create a new page $p->newpage; #select black to do border $p->setcolour("black"); $p->box(10,10,50,50); #select a shade of grey $p->setcolour("grey50"); $p->box( {filled => 1}, 10,10,50,50); $p->output("file.ps");

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://930094]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2014-09-22 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls