I want to use some JavaScript tools located on the following github repo: GitHub - mfogel/polygon-clipping: Apply boolean polygon clipping operations (union, intersection, difference, xor) to your Polygons & MultiPolygons.
I’ve tried installing with npm and then pointing a tag to the library but I must be doing something wrong?
Please help!
I suspect this is a very simple process to follow but I just can’t get it to work.
Just copy the code that you need to a separate tab
So copy all code from the ~15 source module folders?
Isn’t there a better way to use external code that is more robust managing dependencies and code versions?
Perhaps some equivalent to require() or import that works with p5.js??
1 Like
mnse
4
Hi @Broccaaa,
just put this in your html and use it …
<script src="https://cdn.jsdelivr.net/npm/polygon-clipping@0.15.3/dist/polygon-clipping.umd.min.js">/script>
Cheers
— mnse
1 Like
Yes thank you!
It was this bundled/minimized script I needed.
File “package.json” has a “browser” entry w/ “dist/polygon-clipping.umd.js”:
That library is primarily for NodeJS. That’s why we have to look for the “browser” version file.
BtW, here’s a minimalist “index.html” to remotely load both “p5*js” & “polygon-clipping”, plus “sketch.js”:
<script defer src=//cdn.JsDelivr.net/npm/p5></script>
<script defer src=//cdn.JsDelivr.net/npm/polygon-clipping></script>
<script defer src=sketch.js></script>
2 Likes