Closed clozr closed 7 years ago
I've never used react-native. Perhaps you could provide a small test-case for reproduction, or describe the steps required to set things up?
I set up a git repository for you. You can clone this. git clone https://github.com/clozr/react-native-paperjs-example. You will need IOS or Android tools to build and launch the project.
Thanks! But getting this to compile and run may be bit much for me. Are you sure that canvas even works in react-native? A bit of googling brings this up, but that looks unfinished:
React Canvas by Flipboard is maintained (unlike react-native-canvas) and dedicated to mobile performance. It does appear to be predominantly aimed at mobile web instead of native, but worth a look.
I think those are two separate things though?
Lehni, Is there a way around that we don't need canvas to use paperjs. The way react native will work is you will need to get the drawing spec and use react-native-svg to render the component. You may be able to use node-canvas perhaps with rn-nodify. I haven't tried that yet.
There is no SVG backend at the moment, Canvas is the requirement if you want to actually draw something. You can also use the library as you would in a worker to just do vector graphics processing, of course, but that's not the point here.
For displaying content, it looks like fallback to WebView is the only possibility right now. That's also what react-native-canvas is doing internally...
I agree...how about using paperjs to do vector processing e.g path optimization etc. so that we can use part of the paperjs awesomeness in conjunction with react-native-svg? react-native js doesn't have web-worker.
You can use exportSVG()
to export static SVG and display that. Anything beyond that means we finally need to build that SVG backend that we never find time for :)
I am going to close this issue as there is no easy fix for this scenario at the moment until react-native has a proper, native canvas element.
@clozr Did you get any further with this problem? I'd really like to use Paper.js inside a RN project too.
@clozr Did you get any further with this problem? I'd really like to use Paper.js inside a RN project too.
Did you find a way to use Paper.js in RN ?
I am trying to use paper.js with react-native but it fails in getCanvas. Any idea how I may be able to work around it.