Do I have an error in this code or does intersects() not work for a Line?
I notice a bug report at October 2011 that also suggests 2 point lines are not behaving the same as paths with more points?
- --------
When I run this code, I get 'no hit' followed by a list of hits if i use a Line
If I change the line to a thin Rectangle , intersects() seems to work ok.
var testLine = Path.Line(left,y,right,y);
document.activeLayer.appendTop(testLine) ;
// get intersections with hit item
if ( ! testLine.intersects(hitItem) ) {
console.log ('line at ', y, 'intersects says no hit');
}
console.log ('line at ', y, 'intersections are ...');
var locations = testLine.getIntersections(hitItem);
// Loop through the locations (if any):
for(var i = 0; i < locations.length; i++) {
// The position of the intersection:
var point = locations[i].point;
console.log ( point.x, ',' , point.y);
}