Improve a couple of comments.

This commit is contained in:
Jürg Lehni 2016-01-08 01:09:15 +01:00
parent eba9601601
commit ba6c1201fe

View file

@ -310,16 +310,14 @@ PathItem.inject(new function() {
length = curves.length, length = curves.length,
roots = [], roots = [],
abs = Math.abs; abs = Math.abs;
// Absolutely horizontal curves may return wrong results, since // Horizontal curves may return wrong results, since the curves are
// the curves are monotonic in y direction and this is an // monotonic in y direction and this is an indeterminate state.
// indeterminate state.
if (horizontal) { if (horizontal) {
var yTop = -Infinity, var yTop = -Infinity,
yBottom = Infinity, yBottom = Infinity,
yBefore = py - epsilon, yBefore = py - epsilon,
yAfter = py + epsilon; yAfter = py + epsilon;
// Find the closest top and bottom intercepts for the same vertical // Find the closest top and bottom intercepts for the vertical line.
// line.
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var values = curves[i].values, var values = curves[i].values,
count = Curve.solveCubic(values, 0, px, roots, 0, 1); count = Curve.solveCubic(values, 0, px, roots, 0, 1);
@ -332,8 +330,8 @@ PathItem.inject(new function() {
} }
} }
} }
// Shift the point lying on the horizontal curves by // Shift the point lying on the horizontal curves by half of the
// half of closest top and bottom intercepts. // closest top and bottom intercepts.
yTop = (yTop + py) / 2; yTop = (yTop + py) / 2;
yBottom = (yBottom + py) / 2; yBottom = (yBottom + py) / 2;
if (yTop > -Infinity) if (yTop > -Infinity)
@ -423,11 +421,10 @@ PathItem.inject(new function() {
totalLength += length; totalLength += length;
segment = segment.getNext(); segment = segment.getNext();
} while (segment && !segment._intersection && segment !== start); } while (segment && !segment._intersection && segment !== start);
// Calculate the average winding among three evenly distributed // Calculate the average winding among three evenly distributed points
// points along this curve chain as a representative winding number. // along this curve chain as a representative winding number. This
// This selection gives a better chance of returning a correct // selection gives a better chance of returning a correct winding than
// winding than equally dividing the curve chain, with the same // equally dividing the curve chain, with the same (amortized) time.
// (amortised) time.
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
// Sample the points at 1/4, 2/4 and 3/4 of the total length: // Sample the points at 1/4, 2/4 and 3/4 of the total length:
var length = totalLength * (i + 1) / 4; var length = totalLength * (i + 1) / 4;