Bug #10436 Updated: pdf_setcolor optional parameters not optional
| From: | sniper@php.net | Date: | Sun, 19 Aug 2001 08:29:32 +0000 |
| Subject: | Bug #10436 Updated: pdf_setcolor optional parameters not optional | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-63691@lists.php.net to get a copy of this message | ||
ID: 10436
Updated by: sniper
Reported By: graeme@inetix.com.au
Old Status: Open
Status: Closed
Bug Type: PDF related
Operating System: Linux x86
PHP Version: 4.0 Latest CVS (15/04/2001)
New Comment:
This is fixed in CVS. Try the latest snapshot: http://snaps.php.net/
Previous Comments:
------------------------------------------------------------------------
[2001-04-21 22:30:38] graeme@inetix.com.au
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 this bug report at http://bugs.php.net/?id=10436&edit=1