JS-Drawer
/ / 点击 / 阅读耗时 1 分钟Javascript drawer tool, use to draw something and animate it.
If you like it, STAR it please :)
Online demo: Demo
Source code: Code
Installation
npm install --save js-drawer
Example Code
1 | import Drawer from 'js-drawer'; |
Drawer configuration
Name | Type | Desc | Default | Required |
---|---|---|---|---|
container | DOM Object | DOM element | body | false |
width | Number | Canvas width | 400 | false |
height | Number | Canvas height | 400 | false |
size | Number | Stroke size | 1 | false |
color | String | Stroke color | #000000 | false |
speed | Number | Animation speed | 20 | false |
loop | Number | Animation next loop waiting time | 3000 | false |
Drawer API
Name | Type | Desc | Parameter | Param Example |
---|---|---|---|---|
setColor | Function | Set stroke color before draw next line | color<String> | #fff |
setSize | Function | Set stroke size before draw next line | size<Number> | 20 |
setState | Function | Set stroke state before draw next line | state<String> | pen / pencil / rect |
animate | Function | Make animation use exsiting graph |
License
MIT