[Perl-pdf-devel] color example (answer)
Status: Beta
Brought to you by:
ftassin
|
From: Christopher H. <ch...@ch...> - 2002-01-14 15:44:24
|
Someone asked for an example of using colors in PDF::Create. I looked on
the SF archive of the mailing list and it supressed their e-mail address.
So here it is for everybody:
if ($greenbarflag eq 'grey') {
$page->setrgbcolor(.9,0.9,.9); # 10% grey
} else {
$page->setrgbcolor(.9,1,.9); # light green
}
foreach my $bar (@greenbar) {
$page->rectangle(@$bar);
$page->fill();
}
$page->setrgbcolor(0,0,0);
@greenbar is an array of arrayrefs that I calculate elsewhere for making
rectangles like used to be on green bar computer print-outs. Other than
being somewhat bewildered by what the color model was for the first few
tries, it was trivial. $page->setrgbcolor(240,255,240) chewed up lots of
ink. :)
--
</chris>
Q. What's the difference between Batman and Bill Gates?
A. When Batman fought the Penguin, he won.
|