zengm-games / facesjs

A JavaScript library for generating vector-based cartoon faces

Home Page:https://zengm.com/facesjs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serverside Version

mcottingham opened this issue · comments

Hello,

I'm loving the potential of this library, but I'm finding it difficult to use only on the client side. Do you have plans to release a server side version?

The generate function should already work on the server, if that's all you're interested in. If you want to generate SVGs server side, that is not supported now. You could try using jsdom to render it to a fake <svg> element and extract it from that... I'm not sure if that would work.

I could also imagine another API like renderToSVGString(face) that just returns the actual SVG file. I don't have any plans to work on that because I don't need it personally, but I'd be open to a PR if you or anyone else wants to work on it :)

Hey @dumbmatter - I decided to give this a shot, and might have a working POC. It's still not "done", and would love some of your thoughts in my PR below. I did this as a fork from yours, and would need to think about how to merge it into your repo (if you like it)

tomkennedy22#2

Hey @dumbmatter - I decided to give this a shot, and might have a working POC. It's still not "done", and would love some of your thoughts in my PR below. I did this as a fork from yours, and would need to think about how to merge it into your repo (if you like it)

tomkennedy22#2

JK - I figured out how to PR directly to your repo. Happy for any feedback! - #29

@tomkennedy22 there is also another PR #28 which was actually updated a few weeks ago (sorry I didn't notice @gurushida but thanks for replying to my comments!). Can you take a look at that and see if it would work for you too, or if you have any comments on it? The main advantage of #28 compares to yours is it has no changes to the current client-side code (such as display.js), meaning that the bundle size in the browser will not be increased by adding this feature.

Version 4 includes a faceToSvgString function you can use to export faces as SVGs from a Node.js script, as well as a CLI program you can use for the same purpose. The README has more details.