canvas动态设置setStrokeStyle后无法继续画图?
发布于 6 年前 作者 xiazhu 1219 次浏览 来自 官方Issues
this.ctx = context;
    this.prePoint = undefined;
    this.pointsCache = [];
 
 
    var scaleH = opts.width / DevInfo.prototype.X_MAX;
    var scaleW = opts.height / DevInfo.prototype.Y_MAX;
    var scale = (scaleW>scaleH) ? scaleH : scaleW;
    // var scale = 0.04
    console.log(scale)
    this.ctx.scale(scale, scale);
    this.ctx.setStrokeStyle(opts.color)
  // this.ctx.strokeStyle = opts.color
    this.ctx.setLineWidth(opts.lineWidth);
    // console.log(this.ctx)
    // this.ctx.translate(50, 50)
    // console.log("scale:" + scale);
    // this.ctx.moveTo(20,100)  //设置绘画路线的起点 (20,100)>>>(当前画布对象的 x 轴,当前画布对象的 y 轴)
    // this.ctx.lineTo(120, 100)  //增加一个新点,然后创建一条从上次指定点到目标点的线。(120,100)>>>(当前画布对象的 x 轴,当前画布对象的 y 轴)
    // this.ctx.stroke()  //画出当前路径的边框。默认颜色色为黑色。
    // this.ctx.draw(true)
1 回复

你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部