mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Prebuilt module for commit 169b18a5699e613224b6bdc84e1ad65a53151291
This commit is contained in:
parent
86ffb832fa
commit
86454f3eb1
6 changed files with 215 additions and 227 deletions
138
dist/docs/assets/js/paper.js
vendored
138
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Fri Dec 13 16:13:56 2019 +0100
|
* Date: Fri Dec 13 16:45:03 2019 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -916,42 +916,40 @@ var PaperScopeItem = Base.extend(Emitter, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var CollisionDetection = {
|
var CollisionDetection = {
|
||||||
|
findItemBoundsCollisions: function(items1, items2, tolerance,
|
||||||
findItemBoundsCollisions: function(itemsA, itemsB, tolerance,
|
sweepVertical, onlySweepAxisCollisions) {
|
||||||
sweepVertical, onlySweepAxisCollisions) {
|
var bounds1 = new Array(items1.length),
|
||||||
var boundsArr1 = new Array(itemsA.length),
|
bounds2;
|
||||||
boundsArr2;
|
for (var i = 0; i < items1.length; i++) {
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
var bounds = items1[i].bounds;
|
||||||
var bounds = itemsA[i].bounds;
|
bounds1[i] = [bounds.left, bounds.top, bounds.right, bounds.bottom];
|
||||||
boundsArr1[i] = [bounds.left, bounds.top, bounds.right,
|
|
||||||
bounds.bottom];
|
|
||||||
}
|
}
|
||||||
if (itemsB) {
|
if (items2) {
|
||||||
if (itemsB === itemsA) {
|
if (items2 === items1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(itemsB.length);
|
bounds2 = new Array(items2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < items2.length; i++) {
|
||||||
var bounds = itemsB[i].bounds;
|
var bounds = items2[i].bounds;
|
||||||
boundsArr2[i] = [bounds.left, bounds.top, bounds.right,
|
bounds2[i] = [bounds.left, bounds.top, bounds.right,
|
||||||
bounds.bottom];
|
bounds.bottom];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2, tolerance || 0,
|
return this.findBoundsCollisions(bounds1, bounds2, tolerance || 0,
|
||||||
sweepVertical, onlySweepAxisCollisions);
|
sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
||||||
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
||||||
var min = Math.min,
|
var min = Math.min,
|
||||||
max = Math.max,
|
max = Math.max,
|
||||||
boundsArr1 = new Array(curvesValues1.length),
|
bounds1 = new Array(curvesValues1.length),
|
||||||
boundsArr2;
|
bounds2;
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
for (var i = 0; i < bounds1.length; i++) {
|
||||||
var v1 = curvesValues1[i];
|
var v1 = curvesValues1[i];
|
||||||
boundsArr1[i] = [
|
bounds1[i] = [
|
||||||
min(v1[0], v1[2], v1[4], v1[6]),
|
min(v1[0], v1[2], v1[4], v1[6]),
|
||||||
min(v1[1], v1[3], v1[5], v1[7]),
|
min(v1[1], v1[3], v1[5], v1[7]),
|
||||||
max(v1[0], v1[2], v1[4], v1[6]),
|
max(v1[0], v1[2], v1[4], v1[6]),
|
||||||
|
@ -960,12 +958,12 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
if (curvesValues2) {
|
if (curvesValues2) {
|
||||||
if (curvesValues2 === curvesValues1) {
|
if (curvesValues2 === curvesValues1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(curvesValues2.length);
|
bounds2 = new Array(curvesValues2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < bounds2.length; i++) {
|
||||||
var v2 = curvesValues2[i];
|
var v2 = curvesValues2[i];
|
||||||
boundsArr2[i] = [
|
bounds2[i] = [
|
||||||
min(v2[0], v2[2], v2[4], v2[6]),
|
min(v2[0], v2[2], v2[4], v2[6]),
|
||||||
min(v2[1], v2[3], v2[5], v2[7]),
|
min(v2[1], v2[3], v2[5], v2[7]),
|
||||||
max(v2[0], v2[2], v2[4], v2[6]),
|
max(v2[0], v2[2], v2[4], v2[6]),
|
||||||
|
@ -974,8 +972,8 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2,
|
return this.findBoundsCollisions(bounds1, bounds2,
|
||||||
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
||||||
|
@ -1016,7 +1014,8 @@ var CollisionDetection = {
|
||||||
for (var i = 0; i < countAll; i++) {
|
for (var i = 0; i < countAll; i++) {
|
||||||
var currentIndex = allIndicesByP0[i],
|
var currentIndex = allIndicesByP0[i],
|
||||||
currentBounds = allBounds[currentIndex],
|
currentBounds = allBounds[currentIndex],
|
||||||
currentOriginalIndex = self ? currentIndex
|
currentOriginalIndex = self
|
||||||
|
? currentIndex
|
||||||
: currentIndex - countA,
|
: currentIndex - countA,
|
||||||
isCurrentA = currentIndex < countA,
|
isCurrentA = currentIndex < countA,
|
||||||
isCurrentB = self || currentIndex >= countA,
|
isCurrentB = self || currentIndex >= countA,
|
||||||
|
@ -1069,7 +1068,7 @@ var CollisionDetection = {
|
||||||
if (activeIndicesByP1.length) {
|
if (activeIndicesByP1.length) {
|
||||||
var currentP1 = currentBounds[coordP1],
|
var currentP1 = currentBounds[coordP1],
|
||||||
insertIndex =
|
insertIndex =
|
||||||
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
||||||
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
||||||
} else {
|
} else {
|
||||||
activeIndicesByP1.push(currentIndex);
|
activeIndicesByP1.push(currentIndex);
|
||||||
|
@ -7472,9 +7471,9 @@ new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
||||||
_returnFirst) {
|
_returnFirst) {
|
||||||
var epsilon = Numerical.GEOMETRIC_EPSILON;
|
var epsilon = 1e-7,
|
||||||
var self = !curves2;
|
self = !curves2;
|
||||||
if (self)
|
if (self)
|
||||||
curves2 = curves1;
|
curves2 = curves1;
|
||||||
var length1 = curves1.length,
|
var length1 = curves1.length,
|
||||||
|
@ -7484,17 +7483,15 @@ new function() {
|
||||||
locations = [];
|
locations = [];
|
||||||
|
|
||||||
for (var i = 0; i < length1; i++) {
|
for (var i = 0; i < length1; i++) {
|
||||||
var v = curves1[i].getValues(matrix1);
|
values1[i] = curves1[i].getValues(matrix1);
|
||||||
values1[i] = v;
|
|
||||||
}
|
}
|
||||||
if (!self) {
|
if (!self) {
|
||||||
for (var i = 0; i < length2; i++) {
|
for (var i = 0; i < length2; i++) {
|
||||||
var v = curves2[i].getValues(matrix2);
|
values2[i] = curves2[i].getValues(matrix2);
|
||||||
values2[i] = v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
||||||
values1, self ? null : values2, epsilon);
|
values1, self ? null : values2, epsilon);
|
||||||
for (var index1 = 0; index1 < length1; index1++) {
|
for (var index1 = 0; index1 < length1; index1++) {
|
||||||
var curve1 = curves1[index1],
|
var curve1 = curves1[index1],
|
||||||
v1 = values1[index1];
|
v1 = values1[index1];
|
||||||
|
@ -7511,8 +7508,7 @@ new function() {
|
||||||
var curve2 = curves2[index2],
|
var curve2 = curves2[index2],
|
||||||
v2 = values2[index2];
|
v2 = values2[index2];
|
||||||
getCurveIntersections(
|
getCurveIntersections(
|
||||||
v1, v2, curve1, curve2, locations, include
|
v1, v2, curve1, curve2, locations, include);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10335,34 +10331,34 @@ PathItem.inject(new function() {
|
||||||
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
var vertCurveCollisions =
|
var verCurveCollisions =
|
||||||
CollisionDetection.findCurveBoundsCollisions(
|
CollisionDetection.findCurveBoundsCollisions(
|
||||||
curvesValues, curvesValues, 0, true, true);
|
curvesValues, curvesValues, 0, true, true);
|
||||||
var vertCurvesMap = {};
|
var verCurvesMap = {};
|
||||||
for (var i = 0; i < curves.length; i++) {
|
for (var i = 0; i < curves.length; i++) {
|
||||||
var curve = curves[i],
|
var curve = curves[i],
|
||||||
collidingCurves = [],
|
collidingCurves = [],
|
||||||
collisionIndices = vertCurveCollisions[i];
|
collisionIndices = verCurveCollisions[i];
|
||||||
if (collisionIndices) {
|
if (collisionIndices) {
|
||||||
for (var j = 0; j < collisionIndices.length; j++) {
|
for (var j = 0; j < collisionIndices.length; j++) {
|
||||||
collidingCurves.push(curves[collisionIndices[j]]);
|
collidingCurves.push(curves[collisionIndices[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = curve.getPath().getId();
|
var pathId = curve.getPath().getId();
|
||||||
vertCurvesMap[pathId] = vertCurvesMap[pathId] || {};
|
verCurvesMap[pathId] = verCurvesMap[pathId] || {};
|
||||||
vertCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
verCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0, l = crossings.length; i < l; i++) {
|
for (var i = 0, l = crossings.length; i < l; i++) {
|
||||||
propagateWinding(crossings[i]._segment, _path1, _path2,
|
propagateWinding(crossings[i]._segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
for (var i = 0, l = segments.length; i < l; i++) {
|
for (var i = 0, l = segments.length; i < l; i++) {
|
||||||
var segment = segments[i],
|
var segment = segments[i],
|
||||||
inter = segment._intersection;
|
inter = segment._intersection;
|
||||||
if (!segment._winding) {
|
if (!segment._winding) {
|
||||||
propagateWinding(segment, _path1, _path2,
|
propagateWinding(segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
if (!(inter && inter._overlap))
|
if (!(inter && inter._overlap))
|
||||||
segment._path._overlapsOnly = false;
|
segment._path._overlapsOnly = false;
|
||||||
|
@ -10450,21 +10446,21 @@ PathItem.inject(new function() {
|
||||||
clockwise = first.isClockwise();
|
clockwise = first.isClockwise();
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
var path1 = sorted[i],
|
var path1 = sorted[i],
|
||||||
indicesI = collisions[i],
|
|
||||||
entry1 = lookup[path1._id],
|
entry1 = lookup[path1._id],
|
||||||
containerWinding = 0;
|
containerWinding = 0,
|
||||||
if (indicesI) {
|
indices = collisions[i];
|
||||||
|
if (indices) {
|
||||||
var point = null;
|
var point = null;
|
||||||
for (var j = indicesI.length - 1; j >= 0; j--) {
|
for (var j = indices.length - 1; j >= 0; j--) {
|
||||||
if (indicesI[j] < i) {
|
if (indices[j] < i) {
|
||||||
point = point || path1.getInteriorPoint();
|
point = point || path1.getInteriorPoint();
|
||||||
var path2 = sorted[indicesI[j]];
|
var path2 = sorted[indices[j]];
|
||||||
if (path2.contains(point)) {
|
if (path2.contains(point)) {
|
||||||
var entry2 = lookup[path2._id];
|
var entry2 = lookup[path2._id];
|
||||||
containerWinding = entry2.winding;
|
containerWinding = entry2.winding;
|
||||||
entry1.winding += containerWinding;
|
entry1.winding += containerWinding;
|
||||||
entry1.container = entry2.exclude ?
|
entry1.container = entry2.exclude
|
||||||
entry2.container : path2;
|
? entry2.container : path2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10475,8 +10471,8 @@ PathItem.inject(new function() {
|
||||||
paths[entry1.index] = null;
|
paths[entry1.index] = null;
|
||||||
} else {
|
} else {
|
||||||
var container = entry1.container;
|
var container = entry1.container;
|
||||||
path1.setClockwise(container ? !container.isClockwise()
|
path1.setClockwise(
|
||||||
: clockwise);
|
container ? !container.isClockwise() : clockwise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10731,8 +10727,8 @@ PathItem.inject(new function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function propagateWinding(segment, path1, path2, horCurveCollisionsMap,
|
function propagateWinding(segment, path1, path2, horCurvesMap, verCurvesMap,
|
||||||
vertCurveCollisionsMap, operator) {
|
operator) {
|
||||||
var chain = [],
|
var chain = [],
|
||||||
start = segment,
|
start = segment,
|
||||||
totalLength = 0,
|
totalLength = 0,
|
||||||
|
@ -10765,9 +10761,8 @@ PathItem.inject(new function() {
|
||||||
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
||||||
var wind = null;
|
var wind = null;
|
||||||
if (operator.subtract && path2) {
|
if (operator.subtract && path2) {
|
||||||
var pathWinding = operand === path1
|
var otherPath = operand === path1 ? path2 : path1,
|
||||||
? path2._getWinding(pt, dir, true)
|
pathWinding = otherPath._getWinding(pt, dir, true);
|
||||||
: path1._getWinding(pt, dir, true);
|
|
||||||
if (operand === path1 && pathWinding.winding ||
|
if (operand === path1 && pathWinding.winding ||
|
||||||
operand === path2 && !pathWinding.winding) {
|
operand === path2 && !pathWinding.winding) {
|
||||||
if (pathWinding.quality < 1) {
|
if (pathWinding.quality < 1) {
|
||||||
|
@ -10777,12 +10772,13 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = path.getId();
|
if (!wind) {
|
||||||
var curveIndex = curve.getIndex();
|
var pathId = path.getId(),
|
||||||
var hCollisions = horCurveCollisionsMap[pathId][curveIndex];
|
curveIndex = curve.getIndex();
|
||||||
var vCollisions = vertCurveCollisionsMap[pathId][curveIndex];
|
var curvesH = horCurvesMap[pathId][curveIndex],
|
||||||
wind = wind ||
|
curvesV = verCurvesMap[pathId][curveIndex];
|
||||||
getWinding(pt, hCollisions, vCollisions, dir, true);
|
wind = getWinding(pt, curvesH, curvesV, dir, true);
|
||||||
|
}
|
||||||
if (wind.quality > winding.quality)
|
if (wind.quality > winding.quality)
|
||||||
winding = wind;
|
winding = wind;
|
||||||
break;
|
break;
|
||||||
|
|
138
dist/paper-core.js
vendored
138
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Fri Dec 13 16:13:56 2019 +0100
|
* Date: Fri Dec 13 16:45:03 2019 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -913,42 +913,40 @@ var PaperScopeItem = Base.extend(Emitter, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var CollisionDetection = {
|
var CollisionDetection = {
|
||||||
|
findItemBoundsCollisions: function(items1, items2, tolerance,
|
||||||
findItemBoundsCollisions: function(itemsA, itemsB, tolerance,
|
sweepVertical, onlySweepAxisCollisions) {
|
||||||
sweepVertical, onlySweepAxisCollisions) {
|
var bounds1 = new Array(items1.length),
|
||||||
var boundsArr1 = new Array(itemsA.length),
|
bounds2;
|
||||||
boundsArr2;
|
for (var i = 0; i < items1.length; i++) {
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
var bounds = items1[i].bounds;
|
||||||
var bounds = itemsA[i].bounds;
|
bounds1[i] = [bounds.left, bounds.top, bounds.right, bounds.bottom];
|
||||||
boundsArr1[i] = [bounds.left, bounds.top, bounds.right,
|
|
||||||
bounds.bottom];
|
|
||||||
}
|
}
|
||||||
if (itemsB) {
|
if (items2) {
|
||||||
if (itemsB === itemsA) {
|
if (items2 === items1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(itemsB.length);
|
bounds2 = new Array(items2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < items2.length; i++) {
|
||||||
var bounds = itemsB[i].bounds;
|
var bounds = items2[i].bounds;
|
||||||
boundsArr2[i] = [bounds.left, bounds.top, bounds.right,
|
bounds2[i] = [bounds.left, bounds.top, bounds.right,
|
||||||
bounds.bottom];
|
bounds.bottom];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2, tolerance || 0,
|
return this.findBoundsCollisions(bounds1, bounds2, tolerance || 0,
|
||||||
sweepVertical, onlySweepAxisCollisions);
|
sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
||||||
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
||||||
var min = Math.min,
|
var min = Math.min,
|
||||||
max = Math.max,
|
max = Math.max,
|
||||||
boundsArr1 = new Array(curvesValues1.length),
|
bounds1 = new Array(curvesValues1.length),
|
||||||
boundsArr2;
|
bounds2;
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
for (var i = 0; i < bounds1.length; i++) {
|
||||||
var v1 = curvesValues1[i];
|
var v1 = curvesValues1[i];
|
||||||
boundsArr1[i] = [
|
bounds1[i] = [
|
||||||
min(v1[0], v1[2], v1[4], v1[6]),
|
min(v1[0], v1[2], v1[4], v1[6]),
|
||||||
min(v1[1], v1[3], v1[5], v1[7]),
|
min(v1[1], v1[3], v1[5], v1[7]),
|
||||||
max(v1[0], v1[2], v1[4], v1[6]),
|
max(v1[0], v1[2], v1[4], v1[6]),
|
||||||
|
@ -957,12 +955,12 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
if (curvesValues2) {
|
if (curvesValues2) {
|
||||||
if (curvesValues2 === curvesValues1) {
|
if (curvesValues2 === curvesValues1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(curvesValues2.length);
|
bounds2 = new Array(curvesValues2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < bounds2.length; i++) {
|
||||||
var v2 = curvesValues2[i];
|
var v2 = curvesValues2[i];
|
||||||
boundsArr2[i] = [
|
bounds2[i] = [
|
||||||
min(v2[0], v2[2], v2[4], v2[6]),
|
min(v2[0], v2[2], v2[4], v2[6]),
|
||||||
min(v2[1], v2[3], v2[5], v2[7]),
|
min(v2[1], v2[3], v2[5], v2[7]),
|
||||||
max(v2[0], v2[2], v2[4], v2[6]),
|
max(v2[0], v2[2], v2[4], v2[6]),
|
||||||
|
@ -971,8 +969,8 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2,
|
return this.findBoundsCollisions(bounds1, bounds2,
|
||||||
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
||||||
|
@ -1013,7 +1011,8 @@ var CollisionDetection = {
|
||||||
for (var i = 0; i < countAll; i++) {
|
for (var i = 0; i < countAll; i++) {
|
||||||
var currentIndex = allIndicesByP0[i],
|
var currentIndex = allIndicesByP0[i],
|
||||||
currentBounds = allBounds[currentIndex],
|
currentBounds = allBounds[currentIndex],
|
||||||
currentOriginalIndex = self ? currentIndex
|
currentOriginalIndex = self
|
||||||
|
? currentIndex
|
||||||
: currentIndex - countA,
|
: currentIndex - countA,
|
||||||
isCurrentA = currentIndex < countA,
|
isCurrentA = currentIndex < countA,
|
||||||
isCurrentB = self || currentIndex >= countA,
|
isCurrentB = self || currentIndex >= countA,
|
||||||
|
@ -1066,7 +1065,7 @@ var CollisionDetection = {
|
||||||
if (activeIndicesByP1.length) {
|
if (activeIndicesByP1.length) {
|
||||||
var currentP1 = currentBounds[coordP1],
|
var currentP1 = currentBounds[coordP1],
|
||||||
insertIndex =
|
insertIndex =
|
||||||
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
||||||
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
||||||
} else {
|
} else {
|
||||||
activeIndicesByP1.push(currentIndex);
|
activeIndicesByP1.push(currentIndex);
|
||||||
|
@ -7469,9 +7468,9 @@ new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
||||||
_returnFirst) {
|
_returnFirst) {
|
||||||
var epsilon = Numerical.GEOMETRIC_EPSILON;
|
var epsilon = 1e-7,
|
||||||
var self = !curves2;
|
self = !curves2;
|
||||||
if (self)
|
if (self)
|
||||||
curves2 = curves1;
|
curves2 = curves1;
|
||||||
var length1 = curves1.length,
|
var length1 = curves1.length,
|
||||||
|
@ -7481,17 +7480,15 @@ new function() {
|
||||||
locations = [];
|
locations = [];
|
||||||
|
|
||||||
for (var i = 0; i < length1; i++) {
|
for (var i = 0; i < length1; i++) {
|
||||||
var v = curves1[i].getValues(matrix1);
|
values1[i] = curves1[i].getValues(matrix1);
|
||||||
values1[i] = v;
|
|
||||||
}
|
}
|
||||||
if (!self) {
|
if (!self) {
|
||||||
for (var i = 0; i < length2; i++) {
|
for (var i = 0; i < length2; i++) {
|
||||||
var v = curves2[i].getValues(matrix2);
|
values2[i] = curves2[i].getValues(matrix2);
|
||||||
values2[i] = v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
||||||
values1, self ? null : values2, epsilon);
|
values1, self ? null : values2, epsilon);
|
||||||
for (var index1 = 0; index1 < length1; index1++) {
|
for (var index1 = 0; index1 < length1; index1++) {
|
||||||
var curve1 = curves1[index1],
|
var curve1 = curves1[index1],
|
||||||
v1 = values1[index1];
|
v1 = values1[index1];
|
||||||
|
@ -7508,8 +7505,7 @@ new function() {
|
||||||
var curve2 = curves2[index2],
|
var curve2 = curves2[index2],
|
||||||
v2 = values2[index2];
|
v2 = values2[index2];
|
||||||
getCurveIntersections(
|
getCurveIntersections(
|
||||||
v1, v2, curve1, curve2, locations, include
|
v1, v2, curve1, curve2, locations, include);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10332,34 +10328,34 @@ PathItem.inject(new function() {
|
||||||
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
var vertCurveCollisions =
|
var verCurveCollisions =
|
||||||
CollisionDetection.findCurveBoundsCollisions(
|
CollisionDetection.findCurveBoundsCollisions(
|
||||||
curvesValues, curvesValues, 0, true, true);
|
curvesValues, curvesValues, 0, true, true);
|
||||||
var vertCurvesMap = {};
|
var verCurvesMap = {};
|
||||||
for (var i = 0; i < curves.length; i++) {
|
for (var i = 0; i < curves.length; i++) {
|
||||||
var curve = curves[i],
|
var curve = curves[i],
|
||||||
collidingCurves = [],
|
collidingCurves = [],
|
||||||
collisionIndices = vertCurveCollisions[i];
|
collisionIndices = verCurveCollisions[i];
|
||||||
if (collisionIndices) {
|
if (collisionIndices) {
|
||||||
for (var j = 0; j < collisionIndices.length; j++) {
|
for (var j = 0; j < collisionIndices.length; j++) {
|
||||||
collidingCurves.push(curves[collisionIndices[j]]);
|
collidingCurves.push(curves[collisionIndices[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = curve.getPath().getId();
|
var pathId = curve.getPath().getId();
|
||||||
vertCurvesMap[pathId] = vertCurvesMap[pathId] || {};
|
verCurvesMap[pathId] = verCurvesMap[pathId] || {};
|
||||||
vertCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
verCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0, l = crossings.length; i < l; i++) {
|
for (var i = 0, l = crossings.length; i < l; i++) {
|
||||||
propagateWinding(crossings[i]._segment, _path1, _path2,
|
propagateWinding(crossings[i]._segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
for (var i = 0, l = segments.length; i < l; i++) {
|
for (var i = 0, l = segments.length; i < l; i++) {
|
||||||
var segment = segments[i],
|
var segment = segments[i],
|
||||||
inter = segment._intersection;
|
inter = segment._intersection;
|
||||||
if (!segment._winding) {
|
if (!segment._winding) {
|
||||||
propagateWinding(segment, _path1, _path2,
|
propagateWinding(segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
if (!(inter && inter._overlap))
|
if (!(inter && inter._overlap))
|
||||||
segment._path._overlapsOnly = false;
|
segment._path._overlapsOnly = false;
|
||||||
|
@ -10447,21 +10443,21 @@ PathItem.inject(new function() {
|
||||||
clockwise = first.isClockwise();
|
clockwise = first.isClockwise();
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
var path1 = sorted[i],
|
var path1 = sorted[i],
|
||||||
indicesI = collisions[i],
|
|
||||||
entry1 = lookup[path1._id],
|
entry1 = lookup[path1._id],
|
||||||
containerWinding = 0;
|
containerWinding = 0,
|
||||||
if (indicesI) {
|
indices = collisions[i];
|
||||||
|
if (indices) {
|
||||||
var point = null;
|
var point = null;
|
||||||
for (var j = indicesI.length - 1; j >= 0; j--) {
|
for (var j = indices.length - 1; j >= 0; j--) {
|
||||||
if (indicesI[j] < i) {
|
if (indices[j] < i) {
|
||||||
point = point || path1.getInteriorPoint();
|
point = point || path1.getInteriorPoint();
|
||||||
var path2 = sorted[indicesI[j]];
|
var path2 = sorted[indices[j]];
|
||||||
if (path2.contains(point)) {
|
if (path2.contains(point)) {
|
||||||
var entry2 = lookup[path2._id];
|
var entry2 = lookup[path2._id];
|
||||||
containerWinding = entry2.winding;
|
containerWinding = entry2.winding;
|
||||||
entry1.winding += containerWinding;
|
entry1.winding += containerWinding;
|
||||||
entry1.container = entry2.exclude ?
|
entry1.container = entry2.exclude
|
||||||
entry2.container : path2;
|
? entry2.container : path2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10472,8 +10468,8 @@ PathItem.inject(new function() {
|
||||||
paths[entry1.index] = null;
|
paths[entry1.index] = null;
|
||||||
} else {
|
} else {
|
||||||
var container = entry1.container;
|
var container = entry1.container;
|
||||||
path1.setClockwise(container ? !container.isClockwise()
|
path1.setClockwise(
|
||||||
: clockwise);
|
container ? !container.isClockwise() : clockwise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10728,8 +10724,8 @@ PathItem.inject(new function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function propagateWinding(segment, path1, path2, horCurveCollisionsMap,
|
function propagateWinding(segment, path1, path2, horCurvesMap, verCurvesMap,
|
||||||
vertCurveCollisionsMap, operator) {
|
operator) {
|
||||||
var chain = [],
|
var chain = [],
|
||||||
start = segment,
|
start = segment,
|
||||||
totalLength = 0,
|
totalLength = 0,
|
||||||
|
@ -10762,9 +10758,8 @@ PathItem.inject(new function() {
|
||||||
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
||||||
var wind = null;
|
var wind = null;
|
||||||
if (operator.subtract && path2) {
|
if (operator.subtract && path2) {
|
||||||
var pathWinding = operand === path1
|
var otherPath = operand === path1 ? path2 : path1,
|
||||||
? path2._getWinding(pt, dir, true)
|
pathWinding = otherPath._getWinding(pt, dir, true);
|
||||||
: path1._getWinding(pt, dir, true);
|
|
||||||
if (operand === path1 && pathWinding.winding ||
|
if (operand === path1 && pathWinding.winding ||
|
||||||
operand === path2 && !pathWinding.winding) {
|
operand === path2 && !pathWinding.winding) {
|
||||||
if (pathWinding.quality < 1) {
|
if (pathWinding.quality < 1) {
|
||||||
|
@ -10774,12 +10769,13 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = path.getId();
|
if (!wind) {
|
||||||
var curveIndex = curve.getIndex();
|
var pathId = path.getId(),
|
||||||
var hCollisions = horCurveCollisionsMap[pathId][curveIndex];
|
curveIndex = curve.getIndex();
|
||||||
var vCollisions = vertCurveCollisionsMap[pathId][curveIndex];
|
var curvesH = horCurvesMap[pathId][curveIndex],
|
||||||
wind = wind ||
|
curvesV = verCurvesMap[pathId][curveIndex];
|
||||||
getWinding(pt, hCollisions, vCollisions, dir, true);
|
wind = getWinding(pt, curvesH, curvesV, dir, true);
|
||||||
|
}
|
||||||
if (wind.quality > winding.quality)
|
if (wind.quality > winding.quality)
|
||||||
winding = wind;
|
winding = wind;
|
||||||
break;
|
break;
|
||||||
|
|
8
dist/paper-core.min.js
vendored
8
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
138
dist/paper-full.js
vendored
138
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Fri Dec 13 16:13:56 2019 +0100
|
* Date: Fri Dec 13 16:45:03 2019 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -916,42 +916,40 @@ var PaperScopeItem = Base.extend(Emitter, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var CollisionDetection = {
|
var CollisionDetection = {
|
||||||
|
findItemBoundsCollisions: function(items1, items2, tolerance,
|
||||||
findItemBoundsCollisions: function(itemsA, itemsB, tolerance,
|
sweepVertical, onlySweepAxisCollisions) {
|
||||||
sweepVertical, onlySweepAxisCollisions) {
|
var bounds1 = new Array(items1.length),
|
||||||
var boundsArr1 = new Array(itemsA.length),
|
bounds2;
|
||||||
boundsArr2;
|
for (var i = 0; i < items1.length; i++) {
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
var bounds = items1[i].bounds;
|
||||||
var bounds = itemsA[i].bounds;
|
bounds1[i] = [bounds.left, bounds.top, bounds.right, bounds.bottom];
|
||||||
boundsArr1[i] = [bounds.left, bounds.top, bounds.right,
|
|
||||||
bounds.bottom];
|
|
||||||
}
|
}
|
||||||
if (itemsB) {
|
if (items2) {
|
||||||
if (itemsB === itemsA) {
|
if (items2 === items1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(itemsB.length);
|
bounds2 = new Array(items2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < items2.length; i++) {
|
||||||
var bounds = itemsB[i].bounds;
|
var bounds = items2[i].bounds;
|
||||||
boundsArr2[i] = [bounds.left, bounds.top, bounds.right,
|
bounds2[i] = [bounds.left, bounds.top, bounds.right,
|
||||||
bounds.bottom];
|
bounds.bottom];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2, tolerance || 0,
|
return this.findBoundsCollisions(bounds1, bounds2, tolerance || 0,
|
||||||
sweepVertical, onlySweepAxisCollisions);
|
sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
findCurveBoundsCollisions: function(curvesValues1, curvesValues2,
|
||||||
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
tolerance, sweepVertical, onlySweepAxisCollisions) {
|
||||||
var min = Math.min,
|
var min = Math.min,
|
||||||
max = Math.max,
|
max = Math.max,
|
||||||
boundsArr1 = new Array(curvesValues1.length),
|
bounds1 = new Array(curvesValues1.length),
|
||||||
boundsArr2;
|
bounds2;
|
||||||
for (var i = 0; i < boundsArr1.length; i++) {
|
for (var i = 0; i < bounds1.length; i++) {
|
||||||
var v1 = curvesValues1[i];
|
var v1 = curvesValues1[i];
|
||||||
boundsArr1[i] = [
|
bounds1[i] = [
|
||||||
min(v1[0], v1[2], v1[4], v1[6]),
|
min(v1[0], v1[2], v1[4], v1[6]),
|
||||||
min(v1[1], v1[3], v1[5], v1[7]),
|
min(v1[1], v1[3], v1[5], v1[7]),
|
||||||
max(v1[0], v1[2], v1[4], v1[6]),
|
max(v1[0], v1[2], v1[4], v1[6]),
|
||||||
|
@ -960,12 +958,12 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
if (curvesValues2) {
|
if (curvesValues2) {
|
||||||
if (curvesValues2 === curvesValues1) {
|
if (curvesValues2 === curvesValues1) {
|
||||||
boundsArr2 = boundsArr1;
|
bounds2 = bounds1;
|
||||||
} else {
|
} else {
|
||||||
boundsArr2 = new Array(curvesValues2.length);
|
bounds2 = new Array(curvesValues2.length);
|
||||||
for (var i = 0; i < boundsArr2.length; i++) {
|
for (var i = 0; i < bounds2.length; i++) {
|
||||||
var v2 = curvesValues2[i];
|
var v2 = curvesValues2[i];
|
||||||
boundsArr2[i] = [
|
bounds2[i] = [
|
||||||
min(v2[0], v2[2], v2[4], v2[6]),
|
min(v2[0], v2[2], v2[4], v2[6]),
|
||||||
min(v2[1], v2[3], v2[5], v2[7]),
|
min(v2[1], v2[3], v2[5], v2[7]),
|
||||||
max(v2[0], v2[2], v2[4], v2[6]),
|
max(v2[0], v2[2], v2[4], v2[6]),
|
||||||
|
@ -974,8 +972,8 @@ var CollisionDetection = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.findBoundsCollisions(boundsArr1, boundsArr2,
|
return this.findBoundsCollisions(bounds1, bounds2,
|
||||||
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
tolerance || 0, sweepVertical, onlySweepAxisCollisions);
|
||||||
},
|
},
|
||||||
|
|
||||||
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
findBoundsCollisions: function(boundsA, boundsB, tolerance,
|
||||||
|
@ -1016,7 +1014,8 @@ var CollisionDetection = {
|
||||||
for (var i = 0; i < countAll; i++) {
|
for (var i = 0; i < countAll; i++) {
|
||||||
var currentIndex = allIndicesByP0[i],
|
var currentIndex = allIndicesByP0[i],
|
||||||
currentBounds = allBounds[currentIndex],
|
currentBounds = allBounds[currentIndex],
|
||||||
currentOriginalIndex = self ? currentIndex
|
currentOriginalIndex = self
|
||||||
|
? currentIndex
|
||||||
: currentIndex - countA,
|
: currentIndex - countA,
|
||||||
isCurrentA = currentIndex < countA,
|
isCurrentA = currentIndex < countA,
|
||||||
isCurrentB = self || currentIndex >= countA,
|
isCurrentB = self || currentIndex >= countA,
|
||||||
|
@ -1069,7 +1068,7 @@ var CollisionDetection = {
|
||||||
if (activeIndicesByP1.length) {
|
if (activeIndicesByP1.length) {
|
||||||
var currentP1 = currentBounds[coordP1],
|
var currentP1 = currentBounds[coordP1],
|
||||||
insertIndex =
|
insertIndex =
|
||||||
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
binarySearch(activeIndicesByP1, currentP1, coordP1) + 1;
|
||||||
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
activeIndicesByP1.splice(insertIndex, 0, currentIndex);
|
||||||
} else {
|
} else {
|
||||||
activeIndicesByP1.push(currentIndex);
|
activeIndicesByP1.push(currentIndex);
|
||||||
|
@ -7472,9 +7471,9 @@ new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
function getIntersections(curves1, curves2, include, matrix1, matrix2,
|
||||||
_returnFirst) {
|
_returnFirst) {
|
||||||
var epsilon = Numerical.GEOMETRIC_EPSILON;
|
var epsilon = 1e-7,
|
||||||
var self = !curves2;
|
self = !curves2;
|
||||||
if (self)
|
if (self)
|
||||||
curves2 = curves1;
|
curves2 = curves1;
|
||||||
var length1 = curves1.length,
|
var length1 = curves1.length,
|
||||||
|
@ -7484,17 +7483,15 @@ new function() {
|
||||||
locations = [];
|
locations = [];
|
||||||
|
|
||||||
for (var i = 0; i < length1; i++) {
|
for (var i = 0; i < length1; i++) {
|
||||||
var v = curves1[i].getValues(matrix1);
|
values1[i] = curves1[i].getValues(matrix1);
|
||||||
values1[i] = v;
|
|
||||||
}
|
}
|
||||||
if (!self) {
|
if (!self) {
|
||||||
for (var i = 0; i < length2; i++) {
|
for (var i = 0; i < length2; i++) {
|
||||||
var v = curves2[i].getValues(matrix2);
|
values2[i] = curves2[i].getValues(matrix2);
|
||||||
values2[i] = v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(
|
||||||
values1, self ? null : values2, epsilon);
|
values1, self ? null : values2, epsilon);
|
||||||
for (var index1 = 0; index1 < length1; index1++) {
|
for (var index1 = 0; index1 < length1; index1++) {
|
||||||
var curve1 = curves1[index1],
|
var curve1 = curves1[index1],
|
||||||
v1 = values1[index1];
|
v1 = values1[index1];
|
||||||
|
@ -7511,8 +7508,7 @@ new function() {
|
||||||
var curve2 = curves2[index2],
|
var curve2 = curves2[index2],
|
||||||
v2 = values2[index2];
|
v2 = values2[index2];
|
||||||
getCurveIntersections(
|
getCurveIntersections(
|
||||||
v1, v2, curve1, curve2, locations, include
|
v1, v2, curve1, curve2, locations, include);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10335,34 +10331,34 @@ PathItem.inject(new function() {
|
||||||
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
horCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
var vertCurveCollisions =
|
var verCurveCollisions =
|
||||||
CollisionDetection.findCurveBoundsCollisions(
|
CollisionDetection.findCurveBoundsCollisions(
|
||||||
curvesValues, curvesValues, 0, true, true);
|
curvesValues, curvesValues, 0, true, true);
|
||||||
var vertCurvesMap = {};
|
var verCurvesMap = {};
|
||||||
for (var i = 0; i < curves.length; i++) {
|
for (var i = 0; i < curves.length; i++) {
|
||||||
var curve = curves[i],
|
var curve = curves[i],
|
||||||
collidingCurves = [],
|
collidingCurves = [],
|
||||||
collisionIndices = vertCurveCollisions[i];
|
collisionIndices = verCurveCollisions[i];
|
||||||
if (collisionIndices) {
|
if (collisionIndices) {
|
||||||
for (var j = 0; j < collisionIndices.length; j++) {
|
for (var j = 0; j < collisionIndices.length; j++) {
|
||||||
collidingCurves.push(curves[collisionIndices[j]]);
|
collidingCurves.push(curves[collisionIndices[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = curve.getPath().getId();
|
var pathId = curve.getPath().getId();
|
||||||
vertCurvesMap[pathId] = vertCurvesMap[pathId] || {};
|
verCurvesMap[pathId] = verCurvesMap[pathId] || {};
|
||||||
vertCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
verCurvesMap[pathId][curve.getIndex()] = collidingCurves;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0, l = crossings.length; i < l; i++) {
|
for (var i = 0, l = crossings.length; i < l; i++) {
|
||||||
propagateWinding(crossings[i]._segment, _path1, _path2,
|
propagateWinding(crossings[i]._segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
for (var i = 0, l = segments.length; i < l; i++) {
|
for (var i = 0, l = segments.length; i < l; i++) {
|
||||||
var segment = segments[i],
|
var segment = segments[i],
|
||||||
inter = segment._intersection;
|
inter = segment._intersection;
|
||||||
if (!segment._winding) {
|
if (!segment._winding) {
|
||||||
propagateWinding(segment, _path1, _path2,
|
propagateWinding(segment, _path1, _path2,
|
||||||
horCurvesMap, vertCurvesMap, operator);
|
horCurvesMap, verCurvesMap, operator);
|
||||||
}
|
}
|
||||||
if (!(inter && inter._overlap))
|
if (!(inter && inter._overlap))
|
||||||
segment._path._overlapsOnly = false;
|
segment._path._overlapsOnly = false;
|
||||||
|
@ -10450,21 +10446,21 @@ PathItem.inject(new function() {
|
||||||
clockwise = first.isClockwise();
|
clockwise = first.isClockwise();
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
var path1 = sorted[i],
|
var path1 = sorted[i],
|
||||||
indicesI = collisions[i],
|
|
||||||
entry1 = lookup[path1._id],
|
entry1 = lookup[path1._id],
|
||||||
containerWinding = 0;
|
containerWinding = 0,
|
||||||
if (indicesI) {
|
indices = collisions[i];
|
||||||
|
if (indices) {
|
||||||
var point = null;
|
var point = null;
|
||||||
for (var j = indicesI.length - 1; j >= 0; j--) {
|
for (var j = indices.length - 1; j >= 0; j--) {
|
||||||
if (indicesI[j] < i) {
|
if (indices[j] < i) {
|
||||||
point = point || path1.getInteriorPoint();
|
point = point || path1.getInteriorPoint();
|
||||||
var path2 = sorted[indicesI[j]];
|
var path2 = sorted[indices[j]];
|
||||||
if (path2.contains(point)) {
|
if (path2.contains(point)) {
|
||||||
var entry2 = lookup[path2._id];
|
var entry2 = lookup[path2._id];
|
||||||
containerWinding = entry2.winding;
|
containerWinding = entry2.winding;
|
||||||
entry1.winding += containerWinding;
|
entry1.winding += containerWinding;
|
||||||
entry1.container = entry2.exclude ?
|
entry1.container = entry2.exclude
|
||||||
entry2.container : path2;
|
? entry2.container : path2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10475,8 +10471,8 @@ PathItem.inject(new function() {
|
||||||
paths[entry1.index] = null;
|
paths[entry1.index] = null;
|
||||||
} else {
|
} else {
|
||||||
var container = entry1.container;
|
var container = entry1.container;
|
||||||
path1.setClockwise(container ? !container.isClockwise()
|
path1.setClockwise(
|
||||||
: clockwise);
|
container ? !container.isClockwise() : clockwise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10731,8 +10727,8 @@ PathItem.inject(new function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function propagateWinding(segment, path1, path2, horCurveCollisionsMap,
|
function propagateWinding(segment, path1, path2, horCurvesMap, verCurvesMap,
|
||||||
vertCurveCollisionsMap, operator) {
|
operator) {
|
||||||
var chain = [],
|
var chain = [],
|
||||||
start = segment,
|
start = segment,
|
||||||
totalLength = 0,
|
totalLength = 0,
|
||||||
|
@ -10765,9 +10761,8 @@ PathItem.inject(new function() {
|
||||||
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
|
||||||
var wind = null;
|
var wind = null;
|
||||||
if (operator.subtract && path2) {
|
if (operator.subtract && path2) {
|
||||||
var pathWinding = operand === path1
|
var otherPath = operand === path1 ? path2 : path1,
|
||||||
? path2._getWinding(pt, dir, true)
|
pathWinding = otherPath._getWinding(pt, dir, true);
|
||||||
: path1._getWinding(pt, dir, true);
|
|
||||||
if (operand === path1 && pathWinding.winding ||
|
if (operand === path1 && pathWinding.winding ||
|
||||||
operand === path2 && !pathWinding.winding) {
|
operand === path2 && !pathWinding.winding) {
|
||||||
if (pathWinding.quality < 1) {
|
if (pathWinding.quality < 1) {
|
||||||
|
@ -10777,12 +10772,13 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var pathId = path.getId();
|
if (!wind) {
|
||||||
var curveIndex = curve.getIndex();
|
var pathId = path.getId(),
|
||||||
var hCollisions = horCurveCollisionsMap[pathId][curveIndex];
|
curveIndex = curve.getIndex();
|
||||||
var vCollisions = vertCurveCollisionsMap[pathId][curveIndex];
|
var curvesH = horCurvesMap[pathId][curveIndex],
|
||||||
wind = wind ||
|
curvesV = verCurvesMap[pathId][curveIndex];
|
||||||
getWinding(pt, hCollisions, vCollisions, dir, true);
|
wind = getWinding(pt, curvesH, curvesV, dir, true);
|
||||||
|
}
|
||||||
if (wind.quality > winding.quality)
|
if (wind.quality > winding.quality)
|
||||||
winding = wind;
|
winding = wind;
|
||||||
break;
|
break;
|
||||||
|
|
18
dist/paper-full.min.js
vendored
18
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/paper.d.ts
vendored
2
dist/paper.d.ts
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Fri Dec 13 16:13:56 2019 +0100
|
* Date: Fri Dec 13 16:45:03 2019 +0100
|
||||||
*
|
*
|
||||||
* This is an auto-generated type definition.
|
* This is an auto-generated type definition.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue