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
Polygon "mask" support #202
base: master
Are you sure you want to change the base?
Conversation
Added full support for polygon mask. Particles can now be generated only inside, outside or on path of polygon generated from given SVG file. In case of "inline" config the particles bounce randomly in specified radius, otherwise bounce off of polygon sides. One drawback is that calculating polygon intersection is expensive and even in chrome (on my not so powerfull pc) 100-200 particles is the recommended ammount. Demo can be seen here: http://particles.vincurekf.cz/demo/
Doesn't seem to be working. Have tried putting the json in both the "shape" and "particles" section but doesn't seem to recognize my SVG. Are there any specific requirements for the SVG? Also, your demo link doesn't seem to be live. Thank you! |
Hi Daniel, I am sorry about the link, here is working example: For your problem. Is the SVG in the right format? Check the SVG in demo folder: Also, the particlesJS('particles-js',{
"particles": {...},
... rest of the config ...
"polygon": {
"debug": false,
"type": "inline",
"move": {
"radius": 20
},
"url": "svg/deer.svg"
}
}); Sources are here: |
Thanks Vinçent, this works perfectly in Firefox but no longer works in Chrome due to the removal of the "getPathSegAtLength" method (see google dev). I tried to use the pathseg polyfill without any success (crash my tab). I'm not an SVG expert and I was wondering if there was another workaround? |
same issue as @yannlodewijck-nurun |
same issue as yann and The Abyss, can't get a workaround for Chrome |
Thanks @yannlodewijck-nurun for noticing. |
@vincurekf I create a PR to your fork. I reduce the polygon generation time from svg, it's almost instant now! |
Reduce time polygon generation (Instant!)
I'm sorry to be the guy to do this, but this doesn't seem to be working in IE (IE 11 or Edge). No console errors though. I'm not sure if maybe the SVG appears really "zoomed" or if it just ignores the shape boundaries altogether. If it is zoom, how would I control the size since this is converted to canvas? |
any news about this issue ?... |
Added full support for polygon mask. Particles can now be generated only inside, outside or on path of polygon generated from given SVG file. In case of "inline" config the particles bounce randomly in specified radius, otherwise bounce off of polygon sides.
New settings:
By setting
debug
to true, the polygon mask will be drawn on canvas.Generating of the polygon from SVG file is limited to the first path found in given SVG file and it should be closed. And in case of
inside
oroutside
settings the path lines should not overlap otherwise you get weird bouncing effect.One drawback is that calculating polygon intersection is expensive and even in chrome (on my not so powerfull pc) 100-200 particles is the recommended ammount. Demo can be seen here: http://particles.vincurekf.cz/demo/