devongovett/pdfkit — pull request #329 by grahamzibar (2014-11-17 22:24:10+00:00)
Title: FIXED Opacity bug

Opacity ONLY worked if we directly called fillColor or strokeColor and
passed an opacity value as the second argument which made all opacity
calls (fillOpacity, strokeOpacity, and opacity) as well as fill,
fillAndStroke, and stroke calls useless if transparency is required.

The issue is that both fillColor and strokeColor automatically set
opacity to the value 1 if no opacity value is passed. This,
unfortunately, overrides any opacity call made before fill, stroke, or
fillAndStroke since these function invoke the fillColor and strokeColor
functions WITHOUT passing a value for opacity.

The only time opacity would work is if colour was being set incorrectly
(eg. a hex colour value without the ‘#’ at the front) and thus
inheriting from the previous vector’s colours (the set value in both
fillColor and strokeColor would be false and thus opacity is never set)

To fix this, I removed the default value of 1 for opacity for both the
fillColor and strokeColor functions in the color.coffee mixin script.

This doesn’t solve the entire problem however since all subsequent
vector calls will inherit the last set opacity value. To resolve this,
I added an explicit call to reset the opacity to 1 within the closePath
function in the vector.coffee mixin script. I am not sure if this is
the best permanent place for this BUT it does resolve the current issue
with opacity.