完美写意
完美写意是一个通过创建写意路径的。
:link:
安装
npm install perfect-freehand
或者
yarn add perfect-freehand
用法
该库导出默认函数getPath ,该函数接受点数组和(可选)options对象,并返回笔划的SVG路径数据。
点的阵列可以是表示点的x,y数对的阵列,和(任选地)压力......
import getPath from 'perfect-freehand'
const path = getPath ( [
[ 0 , 0 ] ,
[ 10 , 5 ] ,
[ 20 , 8 ] ,
] )
const path = getPath ( [
[ 0 , 0 , 0 ] ,
[ 10 , 5 , 0.5 ] ,
[ 20 , 8 , 0.3 ] ,
] )
...或具有x , y和(可选