小程序中使用canvas绘图遇到的问题

1.绘制的图片呈现黑色背景(其实是因为背景是透明的

	// 在onLoad中执行
	let that = this
	//获取画布的大小信息
	var sysInfo = wx.getSystemInfo({
      success: function (res) {
        canvasWidth1 = res.windowWidth * 0.9
        canvasHeight1 = res.windowHeight * 0.8
        ratio = res.windowWidth / 375
        that.setData({
          canvasWidth: canvasWidth1,
          canvasHeight: canvasHeight1
        })
      },
    })

    //绘图的时候加上这句,其实就是绘制一个与画布等大的白色背景
	ctx.setFillStyle('white');//然后就可以赋给fillStyle了
	ctx.fillRect(0,0,this.data.canvasWidth,this.data.canvasHeight);
	······

后续再更新~

发布了50 篇原创文章 · 获赞 4 · 访问量 1282

猜你喜欢

转载自blog.csdn.net/weixin_43910427/article/details/104428978