pmndrs / react-zdog

⚡️🐶 React bindings for zdog
MIT License
443 stars 21 forks source link

Support for SVG as canvas #3

Closed boardfish closed 5 years ago

boardfish commented 5 years ago

I'm currently trying to port something I wrote in plain JS with Zdog to react-zdog, now that I've seen it working. However, I've had a fair few problems with <canvas> elements previously, so an option to use an SVG element instead would be very welcome.

drcmda commented 5 years ago

Yeah, i really dislike rendering out the canvas like that - but i had some problems with using "Illustration" as a base module, but i'll give it another shot. If i can get it to work it would be easier to switch between canvas/svg.

boardfish commented 5 years ago

Thanks for the speedy response – I'll be very glad if using <svg> even becomes the default option, as I'm personally more trusting of it than a <canvas>.

drcmda commented 5 years ago

i guess the hard thing is just that Illustration has to be created once the canvas is rendered out and referenced, which puts it a frame behind which then messes with orchestrating all these loose ends. i'll ping you if i get any further, but if you want to try yourself, that would be super appreciated as well ...

boardfish commented 5 years ago

I don't have much experience in this area, but I'll have a poke around – don't expect me to make too much ground as I'll be pretty busy in the near future. I'll let you know if I find anything.

boardfish commented 5 years ago

Looks like there's a few things that are specific to using canvas (could be wrong), like resetting lineJoin and lineCap, but it should be okay to use an svg element and render with renderGraphSvg rather than renderGraphCanvas. Hopefully that helps.

drcmda commented 5 years ago

I think using Illustration as the base element would be good since it can target either canvas or svg. This could be an option on the react-zdog Illustration component.

drcmda commented 5 years ago

you can control it now via the element property. it defaults to an svg.