openseadragon / svg-overlay

An OpenSeadragon plugin that adds SVG overlay capability.
BSD 3-Clause "New" or "Revised" License
58 stars 28 forks source link

Rasterising SVG to image tiles instead of to the window #8

Open eriksjolund opened 9 years ago

eriksjolund commented 9 years ago

It seems the SVG is drawn on to the window as soon as some zooming or panning happens. Let's say we have a use case where the drawing of the SVG is compute intensive and that the SVG doesn't change too often. Would it make sense to let OpenSeadragon draw the SVG to image tiles with alpha channel instead of to the window? Maybe zooming and panning would be more smooth? Would there be a difference in anti-aliasing? Could this plugin support drawing the SVG to image tiles?

iangilman commented 9 years ago

When you say compute intensive, do you mean that it takes a lot of work to construct the SVG originally (prior to the browser rendering the SVG), or do you mean that it takes a lot of work for the browser to render it?

If it's the former, then sure, you could construct it in the background (either in web workers or in little chunks on the main thread) and add it as it becomes ready. It would make sense to keep it SVG, though.

If it's the latter, then yes, maybe it would be worth drawing in pixels directly on the tiles. You'd have to keep in mind all of the different tiles and their different levels, so you can draw the right thing in the right spot. Rather than using this plugin, you'd probably use the tile-loaded event that's been added recently (https://github.com/openseadragon/openseadragon/pull/659 ... you'll have to use OpenSeadragon master, as it hasn't been released yet).

eriksjolund commented 8 years ago

It is the latter that I am worried about. The more detailed more and complex the SVG is, the longer it will take to rasterise the SVG. It seems unnecessary to rasterise the SVG for every little pan or zoom change. Thanks for the tips of using the tile-loaded event.