Files
2026-01-06 18:00:43 +08:00

62 lines
959 B
JavaScript

export default class WxCanvas {
constructor(ctx, canvasId, isNew, canvasNode) {
this.ctx = ctx
this.canvasId = canvasId
this.chart = null
this.isNew = isNew
if (isNew) {
this.canvasNode = canvasNode
}
this.chart = null
this._init()
}
getContext(contextType) {
return this.ctx
}
setChart(chart) {
this.chart = chart
}
addEventListener() {
// 暂不支持事件监听
}
removeEventListener() {
// 暂不支持事件监听
}
_init() {
const dpr = wx.getSystemInfoSync().pixelRatio
this.ctx.scale(dpr, dpr)
}
// 代理 canvas 方法
setWidth(width) {
// Canvas 2D 不需要手动设置
}
setHeight(height) {
// Canvas 2D 不需要手动设置
}
getWidth() {
return this.canvasNode.width
}
getHeight() {
return this.canvasNode.height
}
addEvtListener() {
// 事件监听
}
removeEvtListener() {
// 移除监听
}
}