123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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;
- }
- }
- setChart(chart) {
- this.chart = chart;
- }
- attachEvent() {
- // noop
- }
- detachEvent() {
- // noop
- }
- getContext(contextType) {
- if (contextType === '2d') {
- return this.ctx;
- }
- }
- // canvasToTempFilePath(opt) {
- // if (!opt.canvasId) {
- // opt.canvasId = this.canvasId;
- // }
- // return wx.canvasToTempFilePath(opt, this);
- // }
- setTransform(a, b, c, d, e, f) {
- if (this.isNew) {
- this.ctx.setTransform(a, b, c, d, e, f);
- } else {
- this.ctx.transform(a, b, c, d, e, f);
- }
- }
- // context operations
- arc(...args) { this.ctx.arc(...args); }
- arcTo(...args) { this.ctx.arcTo(...args); }
- beginPath(...args) { this.ctx.beginPath(...args); }
- bezierCurveTo(...args) { this.ctx.bezierCurveTo(...args); }
- clearRect(...args) { this.ctx.clearRect(...args); }
- clip(...args) { this.ctx.clip(...args); }
- closePath(...args) { this.ctx.closePath(...args); }
- createCircularGradient(...args) { return this.ctx.createCircularGradient(...args); }
- createLinearGradient(...args) { return this.ctx.createLinearGradient(...args); }
- createPattern(...args) { return this.ctx.createPattern(...args); }
- createRadialGradient(...args) { return this.ctx.createRadialGradient(...args); }
- drawImage(...args) { this.ctx.drawImage(...args); }
- fill(...args) { this.ctx.fill(...args); }
- fillRect(...args) { this.ctx.fillRect(...args); }
- fillText(...args) { this.ctx.fillText(...args); }
- lineTo(...args) { this.ctx.lineTo(...args); }
- measureText(...args) { return this.ctx.measureText(...args); }
- moveTo(...args) { this.ctx.moveTo(...args); }
- quadraticCurveTo(...args) { this.ctx.quadraticCurveTo(...args); }
- rect(...args) { this.ctx.rect(...args); }
- restore(...args) { this.ctx.restore(...args); }
- rotate(...args) { this.ctx.rotate(...args); }
- save(...args) { this.ctx.save(...args); }
- scale(...args) { this.ctx.scale(...args); }
- setFillStyle(...args) { this.ctx.setFillStyle(...args); }
- setFontSize(...args) { this.ctx.setFontSize(...args); }
- setGlobalAlpha(...args) { this.ctx.setGlobalAlpha(...args); }
- setLineCap(...args) { this.ctx.setLineCap(...args); }
- setLineDash(...args) { this.ctx.setLineDash(...args); }
- setLineJoin(...args) { this.ctx.setLineJoin(...args); }
- setLineWidth(...args) { this.ctx.setLineWidth(...args); }
- setMiterLimit(...args) { this.ctx.setMiterLimit(...args); }
- setShadow(...args) { this.ctx.setShadow(...args); }
- setStrokeStyle(...args) { this.ctx.setStrokeStyle(...args); }
- setTextAlign(...args) { this.ctx.setTextAlign(...args); }
- setTextBaseline(...args) { this.ctx.setTextBaseline(...args); }
- stroke(...args) { this.ctx.stroke(...args); }
- strokeRect(...args) { this.ctx.strokeRect(...args); }
- strokeText(...args) { this.ctx.strokeText(...args); }
- transform(...args) { this.ctx.transform(...args); }
- translate(...args) { this.ctx.translate(...args); }
- }
|