react-art icon indicating copy to clipboard operation
react-art copied to clipboard

Error with path when render Shape as svg

Open rosskhanas opened this issue 9 years ago • 1 comments

I try to render svg but have an error when rendering Shape.

js/app.js:2271 Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "[object Object]".

I've made a fork of one project to show the issue: https://github.com/rtkhanas/hex-demo

All I did is - I added a single line to render on svg instead of canvas in src/js/index.js:

require('art/modes/current').setCurrent(require('art/modes/svg'));

I suspect that the problem is not with react-art but with art project, but not sure yet.

rosskhanas avatar Sep 28 '16 04:09 rosskhanas

I've met the same problem as yours, I found the 'path' don't work when I want it to draw in svg mode. Here's What I do to solve(Omitted common details):

import ReactART from 'react-art';
// In svg mode
import 'art/modes/svg'; 
import SVGPath from 'art/modes/svg/path';

// instead of 'const path = new ReactART.Path()...'
const path= new SVGPath().move(200, 20)...

OK, it works and the Error never come. Maybe the key is that in svg mode, we need apply the 'art/modes/svg/path' instead of 'ReactART.Path' as the Path constructor function.

AnneBai avatar Oct 08 '18 07:10 AnneBai