svgdotjs / svg.topoly.js

A plugin for SVG.js to convert paths to polygons at a given sample rate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web browser example (without node.js)?

mattsrinc opened this issue · comments

Hi, trying to use svg.topoly.js on a web page, running it in local web server (Python SimpleHTTPServer), with including it like this (also Polylabel, not an issue):

<script src="js/svg.js"></script> <script src="js/polylabel.js"></script> <script type="module" src="js/svg.topoly.js"></script>

I get

Uncaught SyntaxError: The requested module './svg.js' does not provide an export named 'Path'

and

Uncaught TypeError: path.toPoly is not a function

when trying to call it

const canvas = SVG().addTo('body') ... var path = canvas.path(path0) var polygon = path.toPoly()

path0 contains valid SVG path (d attribute) string.

So can one provide working web page example not requiring node.js module install (and running node server) etc?

To use the plugin without a bundler or native esm imports you need to use the bundle from the dist folder. However there was a problem which wasn't fixed yet (#12). I will try to fix that tomorrow.

Ah, OK, thanks. I've been looking to mess with calling export etc yet I've somehow thought the issue is elsewhere. Will wait, thanks again.

This should be fixed with version 1.0.3