Prebuilt module for commit c235d6a917

This commit is contained in:
Paper.js Bot 2018-10-05 07:49:35 +00:00
parent 7c06fc1b46
commit f8cb537fd7
8 changed files with 321 additions and 26 deletions

View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Thu Oct 4 17:26:48 2018 +0200
* Date: Fri Oct 5 09:44:42 2018 +0200
*
***
*
@ -6629,6 +6629,15 @@ statics: {
getParameterAt: '#getTimeAt',
getTimesWithTangent: function () {
var vector = Point.read(arguments);
if (vector.isZero()) {
return [];
}
return Curve.getTimesWithTangent(this.getValues(), vector);
},
getOffsetAtTime: function(t) {
return this.getPartLength(0, t);
},
@ -7298,6 +7307,45 @@ new function() {
return pairs;
}
function getTimesWithTangent(v, point) {
var x0 = v[0], y0 = v[1],
x1 = v[2], y1 = v[3],
x2 = v[4], y2 = v[5],
x3 = v[6], y3 = v[7],
normalized = point.normalize(),
tx = normalized.x,
ty = normalized.y,
ax = 3 * x3 - 9 * x2 + 9 * x1 - 3 * x0,
ay = 3 * y3 - 9 * y2 + 9 * y1 - 3 * y0,
bx = 6 * x2 - 12 * x1 + 6 * x0,
by = 6 * y2 - 12 * y1 + 6 * y0,
cx = 3 * x1 - 3 * x0,
cy = 3 * y1 - 3 * y0,
den = 2 * ax * ty - 2 * ay * tx,
times = [];
if (Math.abs(den) < Numerical.CURVETIME_EPSILON) {
var num = ax * cy - ay * cx;
var den = ax * by - ay * bx;
if (den != 0) {
var t = -num / den;
if (t >= 0 && t <= 1) times.push(t);
}
} else {
var delta = (bx * bx - 4 * ax * cx) * ty * ty +
(-2 * bx * by + 4 * ay * cx + 4 * ax * cy) * tx * ty +
(by * by - 4 * ay * cy) * tx * tx;
var k = bx * ty - by * tx;
if (delta >= 0 && den != 0) {
var d = Math.sqrt(delta);
var t0 = -(k + d) / den;
var t1 = (-k + d) / den;
if (t0 >= 0 && t0 <= 1) times.push(t0);
if (t1 >= 0 && t1 <= 1) times.push(t1);
}
}
return times;
}
return {
getIntersections: function(curve) {
var v1 = this.getValues(),
@ -7309,7 +7357,8 @@ new function() {
statics: {
getOverlaps: getOverlaps,
getIntersections: getIntersections,
getCurveLineIntersections: getCurveLineIntersections
getCurveLineIntersections: getCurveLineIntersections,
getTimesWithTangent: getTimesWithTangent
}
};
});
@ -8914,8 +8963,30 @@ var Path = PathItem.extend({
return offset;
}
return null;
}
},
getOffsetsWithTangent: function() {
var tangent = Point.read(arguments);
if (tangent.isZero()) {
return [];
}
var offsets = [];
var offsetBeforeCurve = 0;
var curves = this.getCurves();
for (var i = 0; i < curves.length; i++) {
var curve = curves[i];
var curveTimes = curve.getTimesWithTangent(tangent);
for (var j = 0; j < curveTimes.length; j++) {
var offset = offsetBeforeCurve + curve.getOffsetAtTime(curveTimes[j]);
if (offsets.indexOf(offset) < 0) {
offsets.push(offset);
}
}
offsetBeforeCurve += curve.length;
}
return offsets;
}
}),
new function() {

View file

@ -1481,6 +1481,47 @@
</div>
</div>
</div>
<div id="gettimeswithtangent-tangent" class="member">
<div class="member-link">
<a name="gettimeswithtangent-tangent" href="#gettimeswithtangent-tangent"><tt><b>getTimesWithTangent</b>(tangent)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Calculates the curve-time parameters where the curve is tangential to provided tangent. Note that tangents at the start or end are included.</p>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>tangent:</tt>
<a href="../classes/Point.html"><tt>Point</tt></a>
&mdash;&nbsp;the tangent to which the curve must be tangential
</li>
</ul>
<ul class="member-list">
<h4>Returns:</h4>
<li>
<tt>Array of <tt>Number</tt>s</tt>&nbsp;&mdash;&nbsp;at most two curve-time parameters, where the curve is tangential to the given tangent
</li>
</ul>
</div>
</div>
</div>

View file

@ -3283,6 +3283,47 @@ for (var i = 0; i < amount + 1; i++) {
</div>
</div>
</div>
<div id="getoffsetswithtangent-tangent" class="member">
<div class="member-link">
<a name="getoffsetswithtangent-tangent" href="#getoffsetswithtangent-tangent"><tt><b>getOffsetsWithTangent</b>(tangent)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Calculates path offsets where the path is tangential to provided tangent. Note that tangent at start or end are included. Tangent at segment point is returned even if only one of its handles is collinear with the provided tangent.</p>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>tangent:</tt>
<a href="../classes/Point.html"><tt>Point</tt></a>
&mdash;&nbsp;the tangent to which the path must be tangential
</li>
</ul>
<ul class="member-list">
<h4>Returns:</h4>
<li>
<tt>Array of <tt>Number</tt>s</tt>&nbsp;&mdash;&nbsp;path offsets where the path is tangential to the provided tangent
</li>
</ul>
</div>
</div>
</div>

77
dist/paper-core.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Thu Oct 4 17:26:48 2018 +0200
* Date: Fri Oct 5 09:44:42 2018 +0200
*
***
*
@ -6629,6 +6629,15 @@ statics: {
getParameterAt: '#getTimeAt',
getTimesWithTangent: function () {
var vector = Point.read(arguments);
if (vector.isZero()) {
return [];
}
return Curve.getTimesWithTangent(this.getValues(), vector);
},
getOffsetAtTime: function(t) {
return this.getPartLength(0, t);
},
@ -7298,6 +7307,45 @@ new function() {
return pairs;
}
function getTimesWithTangent(v, point) {
var x0 = v[0], y0 = v[1],
x1 = v[2], y1 = v[3],
x2 = v[4], y2 = v[5],
x3 = v[6], y3 = v[7],
normalized = point.normalize(),
tx = normalized.x,
ty = normalized.y,
ax = 3 * x3 - 9 * x2 + 9 * x1 - 3 * x0,
ay = 3 * y3 - 9 * y2 + 9 * y1 - 3 * y0,
bx = 6 * x2 - 12 * x1 + 6 * x0,
by = 6 * y2 - 12 * y1 + 6 * y0,
cx = 3 * x1 - 3 * x0,
cy = 3 * y1 - 3 * y0,
den = 2 * ax * ty - 2 * ay * tx,
times = [];
if (Math.abs(den) < Numerical.CURVETIME_EPSILON) {
var num = ax * cy - ay * cx;
var den = ax * by - ay * bx;
if (den != 0) {
var t = -num / den;
if (t >= 0 && t <= 1) times.push(t);
}
} else {
var delta = (bx * bx - 4 * ax * cx) * ty * ty +
(-2 * bx * by + 4 * ay * cx + 4 * ax * cy) * tx * ty +
(by * by - 4 * ay * cy) * tx * tx;
var k = bx * ty - by * tx;
if (delta >= 0 && den != 0) {
var d = Math.sqrt(delta);
var t0 = -(k + d) / den;
var t1 = (-k + d) / den;
if (t0 >= 0 && t0 <= 1) times.push(t0);
if (t1 >= 0 && t1 <= 1) times.push(t1);
}
}
return times;
}
return {
getIntersections: function(curve) {
var v1 = this.getValues(),
@ -7309,7 +7357,8 @@ new function() {
statics: {
getOverlaps: getOverlaps,
getIntersections: getIntersections,
getCurveLineIntersections: getCurveLineIntersections
getCurveLineIntersections: getCurveLineIntersections,
getTimesWithTangent: getTimesWithTangent
}
};
});
@ -8914,8 +8963,30 @@ var Path = PathItem.extend({
return offset;
}
return null;
}
},
getOffsetsWithTangent: function() {
var tangent = Point.read(arguments);
if (tangent.isZero()) {
return [];
}
var offsets = [];
var offsetBeforeCurve = 0;
var curves = this.getCurves();
for (var i = 0; i < curves.length; i++) {
var curve = curves[i];
var curveTimes = curve.getTimesWithTangent(tangent);
for (var j = 0; j < curveTimes.length; j++) {
var offset = offsetBeforeCurve + curve.getOffsetAtTime(curveTimes[j]);
if (offsets.indexOf(offset) < 0) {
offsets.push(offset);
}
}
offsetBeforeCurve += curve.length;
}
return offsets;
}
}),
new function() {

File diff suppressed because one or more lines are too long

77
dist/paper-full.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Thu Oct 4 17:26:48 2018 +0200
* Date: Fri Oct 5 09:44:42 2018 +0200
*
***
*
@ -6629,6 +6629,15 @@ statics: {
getParameterAt: '#getTimeAt',
getTimesWithTangent: function () {
var vector = Point.read(arguments);
if (vector.isZero()) {
return [];
}
return Curve.getTimesWithTangent(this.getValues(), vector);
},
getOffsetAtTime: function(t) {
return this.getPartLength(0, t);
},
@ -7298,6 +7307,45 @@ new function() {
return pairs;
}
function getTimesWithTangent(v, point) {
var x0 = v[0], y0 = v[1],
x1 = v[2], y1 = v[3],
x2 = v[4], y2 = v[5],
x3 = v[6], y3 = v[7],
normalized = point.normalize(),
tx = normalized.x,
ty = normalized.y,
ax = 3 * x3 - 9 * x2 + 9 * x1 - 3 * x0,
ay = 3 * y3 - 9 * y2 + 9 * y1 - 3 * y0,
bx = 6 * x2 - 12 * x1 + 6 * x0,
by = 6 * y2 - 12 * y1 + 6 * y0,
cx = 3 * x1 - 3 * x0,
cy = 3 * y1 - 3 * y0,
den = 2 * ax * ty - 2 * ay * tx,
times = [];
if (Math.abs(den) < Numerical.CURVETIME_EPSILON) {
var num = ax * cy - ay * cx;
var den = ax * by - ay * bx;
if (den != 0) {
var t = -num / den;
if (t >= 0 && t <= 1) times.push(t);
}
} else {
var delta = (bx * bx - 4 * ax * cx) * ty * ty +
(-2 * bx * by + 4 * ay * cx + 4 * ax * cy) * tx * ty +
(by * by - 4 * ay * cy) * tx * tx;
var k = bx * ty - by * tx;
if (delta >= 0 && den != 0) {
var d = Math.sqrt(delta);
var t0 = -(k + d) / den;
var t1 = (-k + d) / den;
if (t0 >= 0 && t0 <= 1) times.push(t0);
if (t1 >= 0 && t1 <= 1) times.push(t1);
}
}
return times;
}
return {
getIntersections: function(curve) {
var v1 = this.getValues(),
@ -7309,7 +7357,8 @@ new function() {
statics: {
getOverlaps: getOverlaps,
getIntersections: getIntersections,
getCurveLineIntersections: getCurveLineIntersections
getCurveLineIntersections: getCurveLineIntersections,
getTimesWithTangent: getTimesWithTangent
}
};
});
@ -8914,8 +8963,30 @@ var Path = PathItem.extend({
return offset;
}
return null;
}
},
getOffsetsWithTangent: function() {
var tangent = Point.read(arguments);
if (tangent.isZero()) {
return [];
}
var offsets = [];
var offsetBeforeCurve = 0;
var curves = this.getCurves();
for (var i = 0; i < curves.length; i++) {
var curve = curves[i];
var curveTimes = curve.getTimesWithTangent(tangent);
for (var j = 0; j < curveTimes.length; j++) {
var offset = offsetBeforeCurve + curve.getOffsetAtTime(curveTimes[j]);
if (offsets.indexOf(offset) < 0) {
offsets.push(offset);
}
}
offsetBeforeCurve += curve.length;
}
return offsets;
}
}),
new function() {

File diff suppressed because one or more lines are too long

6
package-lock.json generated
View file

@ -4936,9 +4936,9 @@
"dev": true
},
"spdx-correct": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.1.tgz",
"integrity": "sha512-hxSPZbRZvSDuOvADntOElzJpenIR7wXJkuoUcUtS0erbgt2fgeaoPIYretfKpslMhfFDY4k0MZ2F5CUzhBsSvQ==",
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.2.tgz",
"integrity": "sha512-q9hedtzyXHr5S0A1vEPoK/7l8NpfkFYTq6iCY+Pno2ZbdZR6WexZFtqeVGkGxW3TEJMN914Z55EnAGMmenlIQQ==",
"dev": true,
"requires": {
"spdx-expression-parse": "^3.0.0",