3

I am trying to find the intersection between them, then using same result to get difference between first path and second one. I am trying this using Snap.path.intersection function in Snap.svg.

here is the link to the function http://snapsvg.io/docs/#Snap.path.intersection

and here is my sample code

var p1='M 185.90092404385516 250 m -170.90092404385516 0 a 170.90092404385516 170.90092404385516 0 1 0 341.8018480877103 0 a 170.90092404385516 170.90092404385516 0 1 0 -341.8018480877103 0';
var p2='M 336.8744227648239 250 m -148.12557723517602 0 a 148.12557723517602 148.12557723517602 0 1 0 296.25115447035205 0 a 148.12557723517602 148.12557723517602 0 1 0 -296.25115447035205 0';
var PAPER=Snap(document.getElementById('svg'));
var path1=PAPER.path(p1);
path1.attr({'fill-opacity':0.3})

var path2=PAPER.path(p2);
path2.attr({'fill-opacity':0.3})
var intersection=Snap.path.intersection(p1, p2);

Now after doing this I am getting and array which has 2 points of intersection, but it also has bezier curve information with t values. I am unable to use this information to create a new path

mak
  • 31
  • 1
  • Can you add in what your ultimate aim is ? Digging into Snap.path.intersection is quite fiddly iirc, when creating new paths (you may need to look into pathSegList in svg, which is deprecated by some browsers, but there are polyfills). There are often alternatives which may be preferable, so if you there is any extra info about the end aim, it may produce some workarounds. – Ian Apr 03 '17 at 12:36
  • What I want to do is union, intersection and difference between paths. Using snap.svg is not compulsory. Since I already did some work in snap.svg. This is why I asked my ques around this approach. – mak Apr 04 '17 at 04:52
  • I'd be tempted to look at http://www.kevlindev.com/geometry/2D/intersections/index.htm I did do an answer, but there were some bugs in it, so have deleted it for the moment. It's quite a lot of work to do the adds/subs etc. You could also look at the code inside svg-edit as I think they do union/sub etc as well. – Ian Apr 04 '17 at 07:46
  • Related: https://stackoverflow.com/q/50011373/4928642 – Qwertiy Apr 25 '18 at 09:01

0 Answers0