offset-polygon icon indicating copy to clipboard operation
offset-polygon copied to clipboard

Problems in coordinate axis arrays

Open hucoooo opened this issue 1 year ago • 2 comments

I applied it in the Threejs project and found that some of them were not extended but contracted. (This is a Chinese translation) image

hucoooo avatar Feb 04 '24 09:02 hucoooo

The contracted data is:

[-14, -6], [-8, -6], [-8, -8], [-6, -8], [-6, -14], [-16, -14], [-16, -8], [-14, -8]],

[6, -7], [7, -7], [7, -6], [12, -6], [12, -7], [13, -7], [13, -12], [12, -12], [12, -13], [7, -13], [7, -12], [6, -12]]

hucoooo avatar Feb 04 '24 09:02 hucoooo

Hey, Have in mind that this is a very simple library which I'm not maintaining anymore, since I found the excellent js-angusj-clipper. It is really robust and I can wholeheartedly recommend it. Here is ofsetting documentation.

Anyway, I re-created your examples in CodeSandbox - https://codesandbox.io/p/sandbox/offset-polygon-issue-4-4f6m8f

From I can see, with offset set to 1, it works as expected: Screenshot 2024-02-04 at 11 47 34

Of course if you increase offset to something larger than the polygon (in this case 3), library will go bonkers: Screenshot 2024-02-04 at 11 47 28

Hope that helps, cheers!

EDIT: Now I think I didn't really respond to your question. If the issue is that offset param is behaving differently, try changing the orientation of the polygon (or multiply offset by -1).

Stanko avatar Feb 04 '24 10:02 Stanko