Move getIntersections2 to PathItem.prototype.

This commit is contained in:
Jürg Lehni 2013-05-24 17:27:56 -07:00
parent e359dd038c
commit 662736ebf2
2 changed files with 9 additions and 9 deletions

View file

@ -7,14 +7,14 @@ var MAX_ITERATE = 20;
/**
* This method is analogous to paperjs#PathItem.getIntersections
*/
function getIntersections2(path1, path2) {
paper.PathItem.prototype.getIntersections2 = function(path) {
// First check the bounds of the two paths. If they don't intersect,
// we don't need to iterate through their curves.
if (!path1.getBounds().touches(path2.getBounds()))
if (!this.getBounds().touches(path.getBounds()))
return [];
var locations = [],
curves1 = path1.getCurves(),
curves2 = path2.getCurves(),
curves1 = this.getCurves(),
curves2 = path.getCurves(),
length2 = curves2.length,
values2 = [], i;
for (var i = 0; i < length2; i++)
@ -36,7 +36,7 @@ function getIntersections2(path1, path2) {
}
}
return locations;
}
};
/**
* This method is analogous to paperjs#Curve.getIntersections

View file

@ -426,7 +426,7 @@ function testIntersections( path1, path2, caption, testname, testdata, nomark) {
if( !nomark ) console.time('fatline x ' + maxCount);
st = getTimestamp();
while(count--){
ixsFatline = getIntersections2( path1, path2 );
ixsFatline = path1.getIntersections2( path2 );
}
t2 = (getTimestamp() - st) / maxCount;
if( !nomark ) console.timeEnd('fatline x ' + maxCount);
@ -498,7 +498,7 @@ function doRandomTests( testdata ){
ixspaper = p1.getIntersections( p2 );
t1 = (getTimestamp() - st);
st = getTimestamp();
ixsfat = getIntersections2( p1, p2 );
ixsfat = p1.getIntersections2( p2 );
t2 = (getTimestamp() - st);
// Check against paperjs output
// tol - tolerence for computed points with in 1/10 th of a pixel