Condensate if / else statements into terniary chain.

And apply the same style to all multi-line if-statements.
This commit is contained in:
Jürg Lehni 2016-01-08 10:22:11 +01:00
parent d186c2d356
commit a5304443a5

View file

@ -372,17 +372,13 @@ PathItem.inject(new function() {
// Horizontal curves with winding == 0 will be completely // Horizontal curves with winding == 0 will be completely
// ignored. // ignored.
if (winding && (py >= yStart && py <= yEnd if (winding && (py >= yStart && py <= yEnd
|| py >= yEnd && py <= yStart)) { || py >= yEnd && py <= yStart)) {
// Calculate the x value for the ray's intersection. // Calculate the x value for the ray's intersection.
var x; var x = py === yStart ? values[0]
if (py === yStart) { : py === yEnd ? values[6]
x = values[0]; : Curve.solveCubic(values, 1, py, roots, 0, 1) === 1
} else if (py === yEnd) { ? Curve.getPoint(values, roots[0]).x
x = values[6]; : null;
} else if (Curve.solveCubic(values, 1, py, roots, 0, 1)
=== 1) {
x = Curve.getPoint(values, roots[0]).x;
}
if (x != null) { if (x != null) {
// Count the intersection of the ray with the // Count the intersection of the ray with the
// monotonic curve if: // monotonic curve if:
@ -392,8 +388,8 @@ PathItem.inject(new function() {
// - or the start of the current curve and the end // - or the start of the current curve and the end
// of the prev curve are on opposite sides of px // of the prev curve are on opposite sides of px
var isWindingChange = winding === -prevWinding; var isWindingChange = winding === -prevWinding;
if (py !== yStart || isWindingChange || if (py !== yStart || isWindingChange
(x - px) * (prevXEnd - px) < 0) { || (x - px) * (prevXEnd - px) < 0) {
if (x < xBefore) { if (x < xBefore) {
windLeft += winding; windLeft += winding;
} else if (x > xAfter) { } else if (x > xAfter) {