Comment 17 for bug 1406458

Revision history for this message
Alvin Penner (apenner) wrote :

>> Is the error still present in the draft version of the SVG 2.0 spec ?

as far as I can tell, the same error is present in both of the above references. The problem is going to show up in the statement
fGradient[k][i][0] /= s;
This statement can potentially lead to a zero-over-zero division, which is indeterminate, and which could easily be interpreted differently by different renderers. Inkscape for example, generates nan in this case. The above patch avoids this issue.

It looks like the original intent was to generate an array of unit vectors with random orientation angles. If this was the case, then it might have been better to first generate a random array of angles from 0 to 360 degrees, and then produce the unit vector from them using sin(theta) and cos(theta). However for reasons of compatibility, perhaps it is too late to rethink this code, since the above patch appears to apply absolutely seamlessly as far as I could tell, by inspecting a few test cases with and without the patch.