Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 952 Bytes

File metadata and controls

39 lines (31 loc) · 952 Bytes

mobile-graphics

基于canvas的手写插件(移动端和pc端均可使用)

安装

npm install mobile-graphics --save

使用

const Graphics = require('mobile-graphics');
const graphics = new Graphics({
    el: document.getElementById('canvas'), // 挂载节点
    linewidth: 2,                          // 线条宽度
    color: '#000',                         // 线条颜色
    background: '#fff'                     // 背景颜色
})

参数

{
    el: document.getElementById('canvas'), // 挂载节点(必填)
    linewidth: 2,                          // 线条宽度
    color: '#000',                         // 线条颜色
    background: '#fff'                     // 背景颜色
}

方法

graphics.clear()    // 清空画布
graphics.previous() // 返回上一步
graphics.save()     // 保存画布(该函数会直接返回一个base64)