You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First: thanks for this handy and super speedy library!
I'd appreciate an example in the docs on how to do clipping of a Line and a Polygone as I'm not that knowledgeable in vector graphics (yet).
Specifically, I'd like like to clip a Line (open path) from a user-defined Polygon (rectangle, but can also be more complex polygon with holes).
Here's what I tried, and I would much appreciate some hints on how to do this correctly.
import*asclipperLibfrom"js-angusj-clipper";// es6 / typescriptasyncfunctionmainAsync(){// create an instance of the library (usually only do this once in your app)constclipper=awaitclipperLib.loadNativeClipperLibInstanceAsync(// let it autodetect which one to use, but also available WasmOnly and AsmJsOnlyclipperLib.NativeClipperLibRequestedFormat.WasmWithAsmJsFallback);constline=[{x: 10,y: 10},{x: 50,y: 50},{x: 100,y: 100}];constrect=[{x: 25,y: 25},{x: 25,y: 75},{x: 75,y: 75},{x: 75,y: 25}];constpolyResult=clipper.clipToPaths({clipType: clipperLib.ClipType.Union,subjectInputs: [{data: rect,closed: true}],clipInputs: [{data: line,closed: false}],subjectFillType: clipperLib.PolyFillType.EvenOdd});console.log("polyResult",polyResult);}mainAsync();
The text was updated successfully, but these errors were encountered:
MentalGear
changed the title
Usage with Line & Polygone
Usage with Line & Polygon
Feb 23, 2023
First: thanks for this handy and super speedy library!
I'd appreciate an example in the docs on how to do clipping of a Line and a Polygone as I'm not that knowledgeable in vector graphics (yet).
Specifically, I'd like like to clip a Line (open path) from a user-defined Polygon (rectangle, but can also be more complex polygon with holes).
Here's what I tried, and I would much appreciate some hints on how to do this correctly.
The text was updated successfully, but these errors were encountered: