xaviergonz / js-angusj-clipper

Polygon and line clipping and offsetting library (Javascript) - a port of Angus Johnson's clipper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offset points are not accurate

Gautam2010 opened this issue · comments

Why my result is not showing accurate

Below Image red is my original border and blue is from Clipper result.

image

const clipper = await clipperLib.loadNativeClipperLibInstanceAsync(
      clipperLib.NativeClipperLibRequestedFormat.AsmJsOnly
    );


    let path: clipperLib.Path = points;
    let offsetInput: clipperLib.OffsetInput = {
      data: path,
      endType: clipperLib.EndType.ClosedPolygon,
      joinType: clipperLib.JoinType.Round
    }

    let offsetInputs = Array<clipperLib.OffsetInput>();
    offsetInputs.push(offsetInput);


    let offsetParam: clipperLib.OffsetParams = {
      delta: offsetDistance,
      offsetInputs: offsetInputs,

    }

by the looks of it you might be using integers too close between them. try multiplying your coordinates by 1000 before processing for example to allow them up to 3 decimals

see https://documentation.help/The-Clipper-Library/Rounding.htm#:~:text=The%20Clipper%20library%20accepts%20integer,%2D%20tiny%20self%2Dintersection%20artefacts.