nornagon / saxi

Tools & library for driving the AxiDraw pen plotter
GNU Affero General Public License v3.0
466 stars 54 forks source link

Long loading and unreadable image with large svg #48

Open Makio64 opened 4 years ago

Makio64 commented 4 years ago

Saxi is slow to load large SVG and the image cant be preview correctly due to the path over it.

image

joining nearby paths: 117294.57983398438ms background-planner.ts:76 planning pen motions: 1688.39501953125ms background-planner.ts:11 serializing: 657.703125ms ui.tsx:229 deserializing: 4153.98486328125ms

I used a grid strategy to reduce the number of collision test on my polygons/lines visibility, and it improves by almost 100 the time to generate my isometric city, I think similar algorithm might help here.

About complex SVG getting impossible to read due to the path, an option to hide the plotter path would be an easy and quick fix.

nornagon commented 4 years ago

I'm surprised that saxi would path across the image that heavily! Would you be able to attach the SVG so that I can try out some performance tweaks?

joinNearby is O(n), it doesn't do any spatial searches. https://github.com/nornagon/saxi/blob/05b0b7b645d2195928f090cbbd42a4f0946b9f22/src/optimization.ts#L33

Makio64 commented 4 years ago

I usually don't use the path sorting cause I want to feel more the algorithms while it's drawing

cant attach SVG but here is two links: svg medium ( 6mo ) svg hardcore ( 22 mo )

Thanks!

Makio64 commented 4 years ago

Hi, @nornagon did you have the opportunity to test them?