Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of use without node.js #47

Open
yurikaz opened this issue Nov 12, 2018 · 5 comments
Open

Example of use without node.js #47

yurikaz opened this issue Nov 12, 2018 · 5 comments

Comments

@yurikaz
Copy link

yurikaz commented Nov 12, 2018

Thanx a lot for you lib
Please can you give a small example of using it without node.js
We have "snake" track and we need to calculate interselections and show it.
is anyone hase the same task ?

@rowanwins
Copy link
Contributor

Hi @yurikaz

Depending on how your app is setup you should be able to use the files within the dist directory of this repo as they have been compiled and are ready for use in the browser.

So for example with the most basic approach you should be able to do something like

// Include one of the dist files in your html doc
<script src="polygon-clipping.min.js"></script>

// Then reference the lib using the polygon-clipping global var that is exposed
<script>
const poly1 = [[[0,0],[2,0],[0,2],[0,0]]]
const poly2 = [[[-1,0],[1,0],[0,1],[-1,0]]]

polygon-clipping.union(poly1, poly2)

</script>

Hope that helps

@yurikaz
Copy link
Author

yurikaz commented Nov 20, 2018

Thanx for your answer.
When I am doing something lile this I have an error
"Uncaught ReferenceError: polygon is not defined"

@yurikaz
Copy link
Author

yurikaz commented Nov 20, 2018

I think if we change in js "polygon-clipping" to "polygonclipping" it will work

@rowanwins
Copy link
Contributor

ah yes of course the hyphen isn't ideal, that said as a temporary work around you can do something like window['polygon-clipping'].union(poly1, poly2)

@mfogel mfogel added this to the v0.13 milestone Jan 29, 2019
@mfogel
Copy link
Owner

mfogel commented Jan 29, 2019

Agreed, it would be good to add to the README quickstart instructions for use directly in the browser. I'll try to fit this into the next non-bug-fix-focused release.

@mfogel mfogel removed this from the v0.14 milestone Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants