Fit icon indicating copy to clipboard operation
Fit copied to clipboard

How do I "fit" the items in an element other than a square?

Open yure-r opened this issue 2 years ago • 5 comments

I know with the library this was based on, SVG Nest, you can nest the shapes inside of other shapes, I was wondering if it was possible to get the parent element, the outer bin, the container element, to be a circle instead of a square?

yure-r avatar Feb 17 '23 02:02 yure-r

I'm trying to implement non-rectangular bins, but when I replace "noFitRectanglePolygon" in "src/workers/nfp.worker.js" to something else that doesn't assume a rectangle like "noFitPolygon" it don't works as expected.

Sadly this project seems to be the best working library port of SVGnest, the only other one I found which might work, json-nest, doesn't include any instructions on how to use, so I guess fixing this issue is easier than getting the other to work. 😑

Edit: after spending a lot of time debugging my best guess is that noFitPolygon implementation for inside no-fit polygons was never tested and is not functional at the moment, since there are a lot of functions with unused variables. I tried writting myself a replacement which worked (albeit, like noFitRectanglePolygon, it doesn't consider all cases).

I ended giving up from working on this project because, for some unknown reason, Fit positioning seems worse than SVG Nest's for my use case, even when using the current unmodified implementation. 😕

qgustavor avatar Dec 24 '23 04:12 qgustavor

I looking for exactly the same. SVGNest is brilliant, but I need something with a more general approach than with SVGs. @qgustavor you were not successfully at all?

Fajeh avatar Jan 18 '24 10:01 Fajeh

I will publish my code then you can see for yourself. Just give me a bit of time, I'm a bit busy now.

qgustavor avatar Jan 18 '24 11:01 qgustavor

@Fajeh I published my changes here: https://github.com/qgustavor/Fit

qgustavor avatar Jan 18 '24 21:01 qgustavor

Thank you very much!

Fajeh avatar Jan 19 '24 07:01 Fajeh