Bug #10436: pdf_setcolor optional parameters not optional
| From: | graeme at inetix dot com dot au | Date: | Sun, 22 Apr 2001 02:30:38 +0000 |
| Subject: | Bug #10436: pdf_setcolor optional parameters not optional | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-52123@lists.php.net to get a copy of this message | ||
From: graeme@inetix.com.au
Operating system: Linux x86
PHP version: 4.0 Latest CVS (15/04/2001)
PHP Bug Type: PDF related
Bug description: pdf_setcolor optional parameters not optional
In pdf_setcolor() which is part of pdflib-4.0 and in the CVS of PHP, pdf_setcolor() can take a
number of paramters depending on the type of color space you choose.
This can be either rgb, gray, pattern, spotcolor or cmyk.
Depending on what colorspace you choose, the paramters c1, c2, c3 and c4 are either optional or
compulsory. For example, if you choose a colorspace of 'rgb' then you only need to specify
c1, c2 and c3. A colorspace of 'cmyk' requires all four and a colorspace of
'gray', 'spotcolor' or 'pattern' merely requires one.
Currently though, you must specify all 4 values with the non-used ones being ignored. If you do not
specify the ignored paramters then the function terminates the script with an error.
For example
pdf_setcolor($pdf, "stroke", "rgb", 0.5, 0.5, 0.5);
should be correct because you only need to specify the reg, green and blue components. In reality
the function must be used as
pdf_setcolor($pdf, "stroke", "rgb", 0.5, 0.5, 0.5, 0.0);
with the fourth paramter being ignored.
The problem is more pronounced when you specify a pattern or gray color
pdf_setcolor($pdf, "fill", "pattern", $pattern);
is what it would logically be, but the function requires
pdf_setcolor($pdf, "fill", "pattern", $pattern, 0.0, 0.0, 0.0);
which IMHO is just confusing and makes the function harder to understand in the long run.
Can the function be changed to make the optional paramters truly optional? A simple switch/case
statement in the function for the colorspace should suffice.
--
Edit Bug report at: http://bugs.php.net/?id=10436&edit=1