javascript - Slice path into two separate paths using paper.js -


I need to 'slice' a big path into two small paths by using a line. For example, your The following configuration can be:

example of slice

path.split function to divide the rectangle, but I do not understand the paper.js API completely and I'm sure The best way to do this is to use the paper at all .js API

For example, I split the original rectangle by the following commands:

  var Start_shape = new paper.Path.Rectangle ([paper.view.center.x - 200, paper.view.center.y - 200], 400); Start_shape.strokecolor = "#aaa"; Start_shape.strokeWidth = 2; Start_shape.fully selected = true; Var p1 = start_shape.split (start_shape.getNearest location ([paper.view.center.x - 40, paper.view.center.y - 250])); Var p2 = initial_ship.plit (start_shape.getNearest location) ([paper.view.center.x + 50, paper.view.center.y + 250]));   

And I get the following:

partition rectangle

I tried to do the following:

  p1.closed = true; P2.closed = true; P1.position.x + = 10;   

I found the required result:

result

But is there a way to make it more clever?

Yes, you path.divide (path2) to a Division Boolean operation . If you clone the project from Gitubb, then for all boolean functions, examples & gt; Scripts & gt; BooleanOperations.html

I do not believe that it currently works because you would only want one line along with it seems more stable with closed paths.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -