mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Condensate if / else statements into terniary chain.
And apply the same style to all multi-line if-statements.
This commit is contained in:
parent
d186c2d356
commit
a5304443a5
1 changed files with 8 additions and 12 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue