Using SVG path syntax in paper.js?

In the raphael.js library , paths are described using the syntax of the SVG path (for example, M98.36,214.208l2.186-1.093V210.2l-3.378,0.117l1.174,4.137L98.36,214.208z , which provides a very compact way to create a figure (especially if your figure is drawn using an external application such as Illustrator).

I'm interested in using the paper.js library (rather than based on SVG), but a first look at the documentation seems to show these paths being built in stages using object methods. This is a completely different approach ("building a path" and "describing a path", one might say), not very suitable for my needs.

So: is there a way to use SVG paths in paper.js? Or a similar solution "path description"?

Link:

+4
source share
1 answer

You can use SVG path syntax as described in Paper.js link for pathData

 var pathData = 'M98.36,214.208l2.186-1.093V210.2l-3.378,0.117l1.174,4.137L98.36,214.208z'; var path = new Path(pathData); path.strokeColor = 'black'; // Scale the copy by 1000%, so we see something path.scale(10); 

And here is an example of Paper.js Sketch

+3
source

Source: https://habr.com/ru/post/1397583/


All Articles