mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Improve debug logging and drawing.
This commit is contained in:
parent
a665175a89
commit
fec479167c
1 changed files with 17 additions and 11 deletions
|
@ -84,7 +84,7 @@ PathItem.inject(new function() {
|
||||||
self.forEach(function(inter) {
|
self.forEach(function(inter) {
|
||||||
new Path.Circle({
|
new Path.Circle({
|
||||||
center: inter.point,
|
center: inter.point,
|
||||||
radius: 3,
|
radius: fontSize / 2 * scaleFactor,
|
||||||
fillColor: 'red'
|
fillColor: 'red'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -144,6 +144,10 @@ PathItem.inject(new function() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scaleFactor = 1 / 3000; // 0.5; // 1 / 3000;
|
||||||
|
var textAngle = 60;
|
||||||
|
var fontSize = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private method for splitting a PathItem at the given intersections.
|
* Private method for splitting a PathItem at the given intersections.
|
||||||
* The routine works for both self intersections and intersections
|
* The routine works for both self intersections and intersections
|
||||||
|
@ -153,7 +157,7 @@ PathItem.inject(new function() {
|
||||||
*/
|
*/
|
||||||
function splitPath(intersections) {
|
function splitPath(intersections) {
|
||||||
if (window.reportIntersections) {
|
if (window.reportIntersections) {
|
||||||
console.log('Intersections', intersections.length);
|
console.log('Intersections', intersections.length / 2);
|
||||||
intersections.forEach(function(inter) {
|
intersections.forEach(function(inter) {
|
||||||
if (inter._other)
|
if (inter._other)
|
||||||
return;
|
return;
|
||||||
|
@ -166,8 +170,9 @@ PathItem.inject(new function() {
|
||||||
'o', !!other._overlap];
|
'o', !!other._overlap];
|
||||||
new Path.Circle({
|
new Path.Circle({
|
||||||
center: inter.point,
|
center: inter.point,
|
||||||
radius: 3,
|
radius: fontSize / 2 * scaleFactor,
|
||||||
strokeColor: 'green'
|
strokeColor: 'green',
|
||||||
|
strokeScaling: false
|
||||||
});
|
});
|
||||||
console.log(log.map(function(v) {
|
console.log(log.map(function(v) {
|
||||||
return v == null ? '-' : v
|
return v == null ? '-' : v
|
||||||
|
@ -440,17 +445,17 @@ PathItem.inject(new function() {
|
||||||
function tracePaths(segments, monoCurves, operation) {
|
function tracePaths(segments, monoCurves, operation) {
|
||||||
var segmentCount = 0;
|
var segmentCount = 0;
|
||||||
var pathCount = 0;
|
var pathCount = 0;
|
||||||
var textAngle = 20;
|
|
||||||
var fontSize = 5 / paper.project.activeLayer.scaling.x;
|
|
||||||
|
|
||||||
function labelSegment(seg, text, color) {
|
function labelSegment(seg, text, color) {
|
||||||
var point = seg.point;
|
var point = seg.point;
|
||||||
var key = Math.round(point.x) + ',' + Math.round(point.y);
|
var key = Math.round(point.x / scaleFactor) + ',' + Math.round(point.y / scaleFactor);
|
||||||
var offset = segmentOffset[key] || 0;
|
var offset = segmentOffset[key] || 0;
|
||||||
segmentOffset[key] = offset + 1;
|
segmentOffset[key] = offset + 1;
|
||||||
|
var size = fontSize * scaleFactor;
|
||||||
var text = new PointText({
|
var text = new PointText({
|
||||||
point: point.add(new Point(fontSize, fontSize / 2)
|
point: point.add(
|
||||||
.rotate(textAngle).add(0, offset * fontSize * 1.2)),
|
new Point(size, size / 2).add(0, offset * size * 1.2)
|
||||||
|
.rotate(textAngle)),
|
||||||
content: text,
|
content: text,
|
||||||
justification: 'left',
|
justification: 'left',
|
||||||
fillColor: color,
|
fillColor: color,
|
||||||
|
@ -458,7 +463,8 @@ PathItem.inject(new function() {
|
||||||
});
|
});
|
||||||
// TODO! PointText should have pivot in #point by default!
|
// TODO! PointText should have pivot in #point by default!
|
||||||
text.pivot = text.globalToLocal(text.point);
|
text.pivot = text.globalToLocal(text.point);
|
||||||
text.rotation = textAngle;
|
text.scale(scaleFactor);
|
||||||
|
text.rotate(textAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawSegment(seg, text, index, color) {
|
function drawSegment(seg, text, index, color) {
|
||||||
|
@ -466,7 +472,7 @@ PathItem.inject(new function() {
|
||||||
return;
|
return;
|
||||||
new Path.Circle({
|
new Path.Circle({
|
||||||
center: seg.point,
|
center: seg.point,
|
||||||
radius: fontSize / 2,
|
radius: fontSize / 2 * scaleFactor,
|
||||||
strokeColor: color,
|
strokeColor: color,
|
||||||
strokeScaling: false
|
strokeScaling: false
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue