in reply to shading boxes using PostScript::Simple

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");

Replies are listed 'Best First'.
Re^2: shading boxes using PostScript::Simple
by roboticus (Chancellor) on Oct 07, 2011 at 10:10 UTC

    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");