mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Prebuilt module for commit 9d6aab3802
This commit is contained in:
parent
f11458e319
commit
16cd46fcbd
5 changed files with 160 additions and 139 deletions
75
dist/docs/assets/js/paper.js
vendored
75
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sat Jul 9 12:54:17 2016 +0200
|
* Date: Sat Jul 9 13:28:50 2016 +0200
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -976,11 +976,11 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiscriminant(a, b, c) {
|
function getDiscriminant(a, b, c) {
|
||||||
function split(a) {
|
function split(v) {
|
||||||
var x = a * 134217729,
|
var x = v * 134217729,
|
||||||
y = a - x,
|
y = v - x,
|
||||||
hi = y + x,
|
hi = y + x,
|
||||||
lo = a - hi;
|
lo = v - hi;
|
||||||
return [hi, lo];
|
return [hi, lo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,8 +1000,11 @@ var Numerical = new function() {
|
||||||
return D;
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNormalizationFactor(x) {
|
function getNormalizationFactor() {
|
||||||
return pow(2, -Math.round(log2(x || MACHINE_EPSILON)));
|
var max = Math.max.apply(Math, arguments);
|
||||||
|
return max && (max < 1e-8 || max > 1e8)
|
||||||
|
? pow(2, -Math.round(log2(max)))
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1055,27 +1058,26 @@ var Numerical = new function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
solveQuadratic: function(a, b, c, roots, min, max) {
|
solveQuadratic: function(a, b, c, roots, min, max) {
|
||||||
var count = 0,
|
var x1, x2 = Infinity;
|
||||||
eMin = min - EPSILON,
|
|
||||||
eMax = max + EPSILON,
|
|
||||||
x1, x2 = Infinity,
|
|
||||||
B = b * -0.5,
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
if (D && abs(D) < MACHINE_EPSILON) {
|
|
||||||
var f = getNormalizationFactor(abs(a) + abs(B) + abs(c));
|
|
||||||
a *= f;
|
|
||||||
b *= f;
|
|
||||||
c *= f;
|
|
||||||
B *= f;
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
}
|
|
||||||
if (abs(a) < EPSILON) {
|
if (abs(a) < EPSILON) {
|
||||||
if (abs(b) < EPSILON)
|
if (abs(b) < EPSILON)
|
||||||
return abs(c) < EPSILON ? -1 : 0;
|
return abs(c) < EPSILON ? -1 : 0;
|
||||||
x1 = -c / b;
|
x1 = -c / b;
|
||||||
} else if (D >= -MACHINE_EPSILON) {
|
} else {
|
||||||
|
b *= -0.5;
|
||||||
|
var D = getDiscriminant(a, b, c);
|
||||||
|
if (D && abs(D) < MACHINE_EPSILON) {
|
||||||
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c));
|
||||||
|
if (f) {
|
||||||
|
a *= f;
|
||||||
|
b *= f;
|
||||||
|
c *= f;
|
||||||
|
D = getDiscriminant(a, b, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (D >= -MACHINE_EPSILON) {
|
||||||
var Q = D < 0 ? 0 : sqrt(D),
|
var Q = D < 0 ? 0 : sqrt(D),
|
||||||
R = B + (B < 0 ? -Q : Q);
|
R = b + (b < 0 ? -Q : Q);
|
||||||
if (R === 0) {
|
if (R === 0) {
|
||||||
x1 = c / a;
|
x1 = c / a;
|
||||||
x2 = -x1;
|
x2 = -x1;
|
||||||
|
@ -1084,19 +1086,23 @@ var Numerical = new function() {
|
||||||
x2 = c / R;
|
x2 = c / R;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFinite(x1) && (min == null || x1 > eMin && x1 < eMax))
|
}
|
||||||
roots[count++] = min == null ? x1 : clamp(x1, min, max);
|
var count = 0,
|
||||||
|
boundless = min == null,
|
||||||
|
minB = min - EPSILON,
|
||||||
|
maxB = max + EPSILON;
|
||||||
|
if (isFinite(x1) && (boundless || x1 > minB && x1 < maxB))
|
||||||
|
roots[count++] = boundless ? x1 : clamp(x1, min, max);
|
||||||
if (x2 !== x1
|
if (x2 !== x1
|
||||||
&& isFinite(x2) && (min == null || x2 > eMin && x2 < eMax))
|
&& isFinite(x2) && (boundless || x2 > minB && x2 < maxB))
|
||||||
roots[count++] = min == null ? x2 : clamp(x2, min, max);
|
roots[count++] = boundless ? x2 : clamp(x2, min, max);
|
||||||
return count;
|
return count;
|
||||||
},
|
},
|
||||||
|
|
||||||
solveCubic: function(a, b, c, d, roots, min, max) {
|
solveCubic: function(a, b, c, d, roots, min, max) {
|
||||||
var x, b1, c2,
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c), abs(d)),
|
||||||
s = Math.max(abs(a), abs(b), abs(c), abs(d));
|
x, b1, c2;
|
||||||
if (s < 1e-8 || s > 1e8) {
|
if (f) {
|
||||||
var f = getNormalizationFactor(s);
|
|
||||||
a *= f;
|
a *= f;
|
||||||
b *= f;
|
b *= f;
|
||||||
c *= f;
|
c *= f;
|
||||||
|
@ -1142,11 +1148,12 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
|
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max),
|
||||||
|
boundless = min == null;
|
||||||
if (isFinite(x) && (count === 0
|
if (isFinite(x) && (count === 0
|
||||||
|| count > 0 && x !== roots[0] && x !== roots[1])
|
|| count > 0 && x !== roots[0] && x !== roots[1])
|
||||||
&& (min == null || x > min - EPSILON && x < max + EPSILON))
|
&& (boundless || x > min - EPSILON && x < max + EPSILON))
|
||||||
roots[count++] = min == null ? x : clamp(x, min, max);
|
roots[count++] = boundless ? x : clamp(x, min, max);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
75
dist/paper-core.js
vendored
75
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sat Jul 9 12:54:17 2016 +0200
|
* Date: Sat Jul 9 13:28:50 2016 +0200
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -976,11 +976,11 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiscriminant(a, b, c) {
|
function getDiscriminant(a, b, c) {
|
||||||
function split(a) {
|
function split(v) {
|
||||||
var x = a * 134217729,
|
var x = v * 134217729,
|
||||||
y = a - x,
|
y = v - x,
|
||||||
hi = y + x,
|
hi = y + x,
|
||||||
lo = a - hi;
|
lo = v - hi;
|
||||||
return [hi, lo];
|
return [hi, lo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,8 +1000,11 @@ var Numerical = new function() {
|
||||||
return D;
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNormalizationFactor(x) {
|
function getNormalizationFactor() {
|
||||||
return pow(2, -Math.round(log2(x || MACHINE_EPSILON)));
|
var max = Math.max.apply(Math, arguments);
|
||||||
|
return max && (max < 1e-8 || max > 1e8)
|
||||||
|
? pow(2, -Math.round(log2(max)))
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1055,27 +1058,26 @@ var Numerical = new function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
solveQuadratic: function(a, b, c, roots, min, max) {
|
solveQuadratic: function(a, b, c, roots, min, max) {
|
||||||
var count = 0,
|
var x1, x2 = Infinity;
|
||||||
eMin = min - EPSILON,
|
|
||||||
eMax = max + EPSILON,
|
|
||||||
x1, x2 = Infinity,
|
|
||||||
B = b * -0.5,
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
if (D && abs(D) < MACHINE_EPSILON) {
|
|
||||||
var f = getNormalizationFactor(abs(a) + abs(B) + abs(c));
|
|
||||||
a *= f;
|
|
||||||
b *= f;
|
|
||||||
c *= f;
|
|
||||||
B *= f;
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
}
|
|
||||||
if (abs(a) < EPSILON) {
|
if (abs(a) < EPSILON) {
|
||||||
if (abs(b) < EPSILON)
|
if (abs(b) < EPSILON)
|
||||||
return abs(c) < EPSILON ? -1 : 0;
|
return abs(c) < EPSILON ? -1 : 0;
|
||||||
x1 = -c / b;
|
x1 = -c / b;
|
||||||
} else if (D >= -MACHINE_EPSILON) {
|
} else {
|
||||||
|
b *= -0.5;
|
||||||
|
var D = getDiscriminant(a, b, c);
|
||||||
|
if (D && abs(D) < MACHINE_EPSILON) {
|
||||||
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c));
|
||||||
|
if (f) {
|
||||||
|
a *= f;
|
||||||
|
b *= f;
|
||||||
|
c *= f;
|
||||||
|
D = getDiscriminant(a, b, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (D >= -MACHINE_EPSILON) {
|
||||||
var Q = D < 0 ? 0 : sqrt(D),
|
var Q = D < 0 ? 0 : sqrt(D),
|
||||||
R = B + (B < 0 ? -Q : Q);
|
R = b + (b < 0 ? -Q : Q);
|
||||||
if (R === 0) {
|
if (R === 0) {
|
||||||
x1 = c / a;
|
x1 = c / a;
|
||||||
x2 = -x1;
|
x2 = -x1;
|
||||||
|
@ -1084,19 +1086,23 @@ var Numerical = new function() {
|
||||||
x2 = c / R;
|
x2 = c / R;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFinite(x1) && (min == null || x1 > eMin && x1 < eMax))
|
}
|
||||||
roots[count++] = min == null ? x1 : clamp(x1, min, max);
|
var count = 0,
|
||||||
|
boundless = min == null,
|
||||||
|
minB = min - EPSILON,
|
||||||
|
maxB = max + EPSILON;
|
||||||
|
if (isFinite(x1) && (boundless || x1 > minB && x1 < maxB))
|
||||||
|
roots[count++] = boundless ? x1 : clamp(x1, min, max);
|
||||||
if (x2 !== x1
|
if (x2 !== x1
|
||||||
&& isFinite(x2) && (min == null || x2 > eMin && x2 < eMax))
|
&& isFinite(x2) && (boundless || x2 > minB && x2 < maxB))
|
||||||
roots[count++] = min == null ? x2 : clamp(x2, min, max);
|
roots[count++] = boundless ? x2 : clamp(x2, min, max);
|
||||||
return count;
|
return count;
|
||||||
},
|
},
|
||||||
|
|
||||||
solveCubic: function(a, b, c, d, roots, min, max) {
|
solveCubic: function(a, b, c, d, roots, min, max) {
|
||||||
var x, b1, c2,
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c), abs(d)),
|
||||||
s = Math.max(abs(a), abs(b), abs(c), abs(d));
|
x, b1, c2;
|
||||||
if (s < 1e-8 || s > 1e8) {
|
if (f) {
|
||||||
var f = getNormalizationFactor(s);
|
|
||||||
a *= f;
|
a *= f;
|
||||||
b *= f;
|
b *= f;
|
||||||
c *= f;
|
c *= f;
|
||||||
|
@ -1142,11 +1148,12 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
|
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max),
|
||||||
|
boundless = min == null;
|
||||||
if (isFinite(x) && (count === 0
|
if (isFinite(x) && (count === 0
|
||||||
|| count > 0 && x !== roots[0] && x !== roots[1])
|
|| count > 0 && x !== roots[0] && x !== roots[1])
|
||||||
&& (min == null || x > min - EPSILON && x < max + EPSILON))
|
&& (boundless || x > min - EPSILON && x < max + EPSILON))
|
||||||
roots[count++] = min == null ? x : clamp(x, min, max);
|
roots[count++] = boundless ? x : clamp(x, min, max);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
16
dist/paper-core.min.js
vendored
16
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
75
dist/paper-full.js
vendored
75
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sat Jul 9 12:54:17 2016 +0200
|
* Date: Sat Jul 9 13:28:50 2016 +0200
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -976,11 +976,11 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiscriminant(a, b, c) {
|
function getDiscriminant(a, b, c) {
|
||||||
function split(a) {
|
function split(v) {
|
||||||
var x = a * 134217729,
|
var x = v * 134217729,
|
||||||
y = a - x,
|
y = v - x,
|
||||||
hi = y + x,
|
hi = y + x,
|
||||||
lo = a - hi;
|
lo = v - hi;
|
||||||
return [hi, lo];
|
return [hi, lo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,8 +1000,11 @@ var Numerical = new function() {
|
||||||
return D;
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNormalizationFactor(x) {
|
function getNormalizationFactor() {
|
||||||
return pow(2, -Math.round(log2(x || MACHINE_EPSILON)));
|
var max = Math.max.apply(Math, arguments);
|
||||||
|
return max && (max < 1e-8 || max > 1e8)
|
||||||
|
? pow(2, -Math.round(log2(max)))
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1055,27 +1058,26 @@ var Numerical = new function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
solveQuadratic: function(a, b, c, roots, min, max) {
|
solveQuadratic: function(a, b, c, roots, min, max) {
|
||||||
var count = 0,
|
var x1, x2 = Infinity;
|
||||||
eMin = min - EPSILON,
|
|
||||||
eMax = max + EPSILON,
|
|
||||||
x1, x2 = Infinity,
|
|
||||||
B = b * -0.5,
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
if (D && abs(D) < MACHINE_EPSILON) {
|
|
||||||
var f = getNormalizationFactor(abs(a) + abs(B) + abs(c));
|
|
||||||
a *= f;
|
|
||||||
b *= f;
|
|
||||||
c *= f;
|
|
||||||
B *= f;
|
|
||||||
D = getDiscriminant(a, B, c);
|
|
||||||
}
|
|
||||||
if (abs(a) < EPSILON) {
|
if (abs(a) < EPSILON) {
|
||||||
if (abs(b) < EPSILON)
|
if (abs(b) < EPSILON)
|
||||||
return abs(c) < EPSILON ? -1 : 0;
|
return abs(c) < EPSILON ? -1 : 0;
|
||||||
x1 = -c / b;
|
x1 = -c / b;
|
||||||
} else if (D >= -MACHINE_EPSILON) {
|
} else {
|
||||||
|
b *= -0.5;
|
||||||
|
var D = getDiscriminant(a, b, c);
|
||||||
|
if (D && abs(D) < MACHINE_EPSILON) {
|
||||||
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c));
|
||||||
|
if (f) {
|
||||||
|
a *= f;
|
||||||
|
b *= f;
|
||||||
|
c *= f;
|
||||||
|
D = getDiscriminant(a, b, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (D >= -MACHINE_EPSILON) {
|
||||||
var Q = D < 0 ? 0 : sqrt(D),
|
var Q = D < 0 ? 0 : sqrt(D),
|
||||||
R = B + (B < 0 ? -Q : Q);
|
R = b + (b < 0 ? -Q : Q);
|
||||||
if (R === 0) {
|
if (R === 0) {
|
||||||
x1 = c / a;
|
x1 = c / a;
|
||||||
x2 = -x1;
|
x2 = -x1;
|
||||||
|
@ -1084,19 +1086,23 @@ var Numerical = new function() {
|
||||||
x2 = c / R;
|
x2 = c / R;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFinite(x1) && (min == null || x1 > eMin && x1 < eMax))
|
}
|
||||||
roots[count++] = min == null ? x1 : clamp(x1, min, max);
|
var count = 0,
|
||||||
|
boundless = min == null,
|
||||||
|
minB = min - EPSILON,
|
||||||
|
maxB = max + EPSILON;
|
||||||
|
if (isFinite(x1) && (boundless || x1 > minB && x1 < maxB))
|
||||||
|
roots[count++] = boundless ? x1 : clamp(x1, min, max);
|
||||||
if (x2 !== x1
|
if (x2 !== x1
|
||||||
&& isFinite(x2) && (min == null || x2 > eMin && x2 < eMax))
|
&& isFinite(x2) && (boundless || x2 > minB && x2 < maxB))
|
||||||
roots[count++] = min == null ? x2 : clamp(x2, min, max);
|
roots[count++] = boundless ? x2 : clamp(x2, min, max);
|
||||||
return count;
|
return count;
|
||||||
},
|
},
|
||||||
|
|
||||||
solveCubic: function(a, b, c, d, roots, min, max) {
|
solveCubic: function(a, b, c, d, roots, min, max) {
|
||||||
var x, b1, c2,
|
var f = getNormalizationFactor(abs(a), abs(b), abs(c), abs(d)),
|
||||||
s = Math.max(abs(a), abs(b), abs(c), abs(d));
|
x, b1, c2;
|
||||||
if (s < 1e-8 || s > 1e8) {
|
if (f) {
|
||||||
var f = getNormalizationFactor(s);
|
|
||||||
a *= f;
|
a *= f;
|
||||||
b *= f;
|
b *= f;
|
||||||
c *= f;
|
c *= f;
|
||||||
|
@ -1142,11 +1148,12 @@ var Numerical = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
|
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max),
|
||||||
|
boundless = min == null;
|
||||||
if (isFinite(x) && (count === 0
|
if (isFinite(x) && (count === 0
|
||||||
|| count > 0 && x !== roots[0] && x !== roots[1])
|
|| count > 0 && x !== roots[0] && x !== roots[1])
|
||||||
&& (min == null || x > min - EPSILON && x < max + EPSILON))
|
&& (boundless || x > min - EPSILON && x < max + EPSILON))
|
||||||
roots[count++] = min == null ? x : clamp(x, min, max);
|
roots[count++] = boundless ? x : clamp(x, min, max);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
16
dist/paper-full.min.js
vendored
16
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue