基於canvas的移動端手寫外掛
阿新 • • 發佈:2018-11-06
mobile-graphics
基於canvas的移動端手寫外掛
github地址:https://github.com/fisher-zh/graphics[https://github.com/fisher-zh/graphics]
安裝
模組化安裝
npm install mobile-graphics --save
直接引入
<!-- 直接在 github 上拉取最新的程式碼,使用 webpack 編譯後引入即可 -->
<script src="./dist/graphics.min.js"></script>
使用
// 直接使用script標籤引入可以直接使用 Graphics 類
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)