当前位置:网站首页>canvas画图时的bug记录
canvas画图时的bug记录
2022-08-04 09:33:00 【尼克_张】
1.重复使用图片的onload事件中处理某些事,出现图片闪烁
在调用画图片的构造函数时,我们可以先在constructor中缓存图片
constructor(){
this.img = new Image();
this.img.src = require("xx");
}
然后再在方法中画图片
this.ctx.drawImage(this.img,width,height)
2.当画布上出现重叠的图像
this.canvasDom = document.getElementById("canvas");
this.ctx = this.canvasDom.getContext("2d");
const {
width, height } = this.canvasDom;
this.width = width;
this.height = height;
先把原先的画布信息存下来
this.imageData = this.ctx.getImageData(
0,
0,
this.width,
this.height
);
清空画布,把存储的画布信息放上去,再加上自己新的内容
ctx.clearRect(0, 0, this.width, this.height);
this.imageData &&
ctx.putImageData(
this.imageData,
0,
0,
0,
0,
this.width,
this.height
);
边栏推荐
猜你喜欢

leetcode单调栈经典例题——最大矩形

外包干了四年,秋招终于上岸了

我和 TiDB 的故事 | 缘份在,那就终是能相遇的

命里有时终须有--记与TiDB的一次次擦肩而过
![Cloud function to achieve automatic website check-in configuration details [Web function/Nodejs/cookie]](/img/56/2ad889a3a740d0a7624b25f6307616.png)
Cloud function to achieve automatic website check-in configuration details [Web function/Nodejs/cookie]

基于cRIO-904X搭建Simulink与Labview环境

2022 Cloud Native Computing代表厂商 | 灵雀云第三次入选Gartner中国ICT技术成熟度曲线报告

我和 TiDB 的故事 | TiDB 对我不离不弃,我亦如此

去掉js代码文件所有注释

路由/三层交换机DHCP下发地址详解【华为eNSP】
随机推荐
Inheritance and the static keyword
ZbxTable 2.0 重磅发布!6大主要优化功能!
什么是元宇宙?
I am 37 this year, and I was rushed by a big factory to...
Ansible deployment scripts - pro available without pit
已解决No module named ‘flask_misaka‘【BUG解决】
华为od项目
VRRP+MSTP配置详解【华为eNSP实验】
TCP的四次挥手
有坦荡的远方
【C补充】指针相关知识点收集01
【无标题】
架构设计杂谈
今日睡眠质量记录71分
Detailed explanation of switch link aggregation [Huawei eNSP]
并发编程之生产者和消费者问题
GBsae 8 c database using an error, how to do?
学习在微信小程序中判断url的文件后缀格式
NAT/NAPT地址转换(内外网通信)技术详解【华为eNSP】
浅聊偏函数