mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Improve boolean debug code.
This commit is contained in:
parent
31771aa01d
commit
4379e0b0f0
1 changed files with 10 additions and 6 deletions
|
@ -79,7 +79,6 @@ PathItem.inject(new function() {
|
||||||
// intersection, _path2 will be null and getIntersections() handles it.
|
// intersection, _path2 will be null and getIntersections() handles it.
|
||||||
splitPath(Curve.filterIntersections(
|
splitPath(Curve.filterIntersections(
|
||||||
_path1._getIntersections(_path2, null, []), true));
|
_path1._getIntersections(_path2, null, []), true));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
console.time('inter');
|
console.time('inter');
|
||||||
var locations = _path1._getIntersections(_path2, null, []);
|
var locations = _path1._getIntersections(_path2, null, []);
|
||||||
|
@ -459,10 +458,11 @@ PathItem.inject(new function() {
|
||||||
*/
|
*/
|
||||||
function tracePaths(segments, monoCurves, operation) {
|
function tracePaths(segments, monoCurves, operation) {
|
||||||
var segmentCount = 0;
|
var segmentCount = 0;
|
||||||
|
var pathCount = 0;
|
||||||
var reportSegments = false && !window.silent;
|
var reportSegments = false && !window.silent;
|
||||||
var reportWindings = false && !window.silent;
|
var reportWindings = false && !window.silent;
|
||||||
var textAngle = 0;
|
var textAngle = 0;
|
||||||
var fontSize = 4 / paper.project.activeLayer.scaling.x;
|
var fontSize = 1 / paper.project.activeLayer.scaling.x;
|
||||||
|
|
||||||
function labelSegment(seg, text, color) {
|
function labelSegment(seg, text, color) {
|
||||||
var point = seg.point;
|
var point = seg.point;
|
||||||
|
@ -470,7 +470,8 @@ PathItem.inject(new function() {
|
||||||
var offset = segmentOffset[key] || 0;
|
var offset = segmentOffset[key] || 0;
|
||||||
segmentOffset[key] = offset + 1;
|
segmentOffset[key] = offset + 1;
|
||||||
var text = new PointText({
|
var text = new PointText({
|
||||||
point: point.add(new Point(fontSize, fontSize / 2).rotate(textAngle).add(0, offset * fontSize * 1.2)),
|
point: point.add(new Point(fontSize, fontSize / 2)
|
||||||
|
.rotate(textAngle).add(0, offset * fontSize * 1.2)),
|
||||||
content: text,
|
content: text,
|
||||||
justification: 'left',
|
justification: 'left',
|
||||||
fillColor: color,
|
fillColor: color,
|
||||||
|
@ -490,7 +491,7 @@ PathItem.inject(new function() {
|
||||||
strokeScaling: false
|
strokeScaling: false
|
||||||
});
|
});
|
||||||
var inter = seg._intersection;
|
var inter = seg._intersection;
|
||||||
labelSegment(seg, '#' + (paths.length + 1) + '.'
|
labelSegment(seg, '#' + (pathCount + 1) + '.'
|
||||||
+ (path ? path._segments.length + 1 : 1)
|
+ (path ? path._segments.length + 1 : 1)
|
||||||
+ ' ' + (segmentCount++) + '/' + index + ': ' + text
|
+ ' ' + (segmentCount++) + '/' + index + ': ' + text
|
||||||
+ ' v: ' + !!seg._visited
|
+ ' v: ' + !!seg._visited
|
||||||
|
@ -658,14 +659,14 @@ PathItem.inject(new function() {
|
||||||
path.setClosed(true);
|
path.setClosed(true);
|
||||||
if (reportSegments) {
|
if (reportSegments) {
|
||||||
console.log('Boolean operation completed',
|
console.log('Boolean operation completed',
|
||||||
'#' + (paths.length + 1) + '.' +
|
'#' + (pathCount + 1) + '.' +
|
||||||
(path ? path._segments.length + 1 : 1));
|
(path ? path._segments.length + 1 : 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// path.lastSegment._handleOut.set(0, 0);
|
// path.lastSegment._handleOut.set(0, 0);
|
||||||
console.error('Boolean operation results in open path, segs =',
|
console.error('Boolean operation results in open path, segs =',
|
||||||
path._segments.length, 'length = ', path.getLength(),
|
path._segments.length, 'length = ', path.getLength(),
|
||||||
'#' + (paths.length + 1) + '.' +
|
'#' + (pathCount + 1) + '.' +
|
||||||
(path ? path._segments.length + 1 : 1));
|
(path ? path._segments.length + 1 : 1));
|
||||||
path = null;
|
path = null;
|
||||||
}
|
}
|
||||||
|
@ -676,6 +677,9 @@ PathItem.inject(new function() {
|
||||||
// - Closed paths with curves can consist of only one segment
|
// - Closed paths with curves can consist of only one segment
|
||||||
if (path && path._segments.length > path.isLinear() ? 2 : 0)
|
if (path && path._segments.length > path.isLinear() ? 2 : 0)
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
|
if (reportSegments) {
|
||||||
|
pathCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue