mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -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
|
||||
// ignored.
|
||||
if (winding && (py >= yStart && py <= yEnd
|
||||
|| py >= yEnd && py <= yStart)) {
|
||||
|| py >= yEnd && py <= yStart)) {
|
||||
// Calculate the x value for the ray's intersection.
|
||||
var x;
|
||||
if (py === yStart) {
|
||||
x = values[0];
|
||||
} else if (py === yEnd) {
|
||||
x = values[6];
|
||||
} else if (Curve.solveCubic(values, 1, py, roots, 0, 1)
|
||||
=== 1) {
|
||||
x = Curve.getPoint(values, roots[0]).x;
|
||||
}
|
||||
var x = py === yStart ? values[0]
|
||||
: py === yEnd ? values[6]
|
||||
: Curve.solveCubic(values, 1, py, roots, 0, 1) === 1
|
||||
? Curve.getPoint(values, roots[0]).x
|
||||
: null;
|
||||
if (x != null) {
|
||||
// Count the intersection of the ray with the
|
||||
// monotonic curve if:
|
||||
|
@ -392,8 +388,8 @@ PathItem.inject(new function() {
|
|||
// - or the start of the current curve and the end
|
||||
// of the prev curve are on opposite sides of px
|
||||
var isWindingChange = winding === -prevWinding;
|
||||
if (py !== yStart || isWindingChange ||
|
||||
(x - px) * (prevXEnd - px) < 0) {
|
||||
if (py !== yStart || isWindingChange
|
||||
|| (x - px) * (prevXEnd - px) < 0) {
|
||||
if (x < xBefore) {
|
||||
windLeft += winding;
|
||||
} else if (x > xAfter) {
|
||||
|
|
Loading…
Reference in a new issue