add canvas extend plugin

This commit is contained in:
jiaming 2018-12-07 15:50:10 +08:00
parent b6c9daf398
commit e7db599043
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,23 @@
export function drawLine (ctx, lineBegin, lineEnd, lineWidth = 2, lineColor = '#000') {
if (!ctx || !lineBegin || !lineEnd) return
ctx.beginPath()
ctx.moveTo(...lineBegin)
ctx.lineTo(...lineEnd)
ctx.closePath()
ctx.lineWidth = lineWidth
ctx.strokeStyle = lineColor
ctx.stroke()
}
const canvas = {
drawLine
}
export default function (Vue) {
Vue.prototype.canvas = canvas
}

View File

@ -1,5 +1,8 @@
import methodsExtend from './methodsExtend' import methodsExtend from './methodsExtend'
import canvasExtend from './canvasExtend'
export default function (Vue) { export default function (Vue) {
methodsExtend(Vue) methodsExtend(Vue)
canvasExtend(Vue)
} }