Search code examples
paperjs

Unite paths, edge cases


I was wondering why is unite of a path composed of only one point, with an other path of 2 points returns nothing! An other case is unite of a two points' path and any other geometrical form , it returns the last item and ignores the 2 points' path. Thank you!

var carre = new Path({
    segments: [[30, 75], [30, 25], [80, 25], [80, 75]],
    strokeColor: 'black',
    closed: true
});

// Select the path, so we can see its handles:
carre.fullySelected = true;

// Create a copy of the path and move it 100pt to the right:
var ligne =  new Path({
    segments: [[30, 75], [41, 25]],
    strokeColor: 'black',
    closed: false
});
ligne.fullySelected = true;
ligne.position.x += 100;

var uniteres = carre.unite(ligne);
uniteres.fullySelected = true;
uniteres.position.x += 200;

Solution

  • You are right to find this weird. In fact I would say that this is a bug in the boolean operation algorithm, which you can report here: https://github.com/paperjs/paper.js/issues