当前位置:网站首页>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
);
边栏推荐
猜你喜欢
随机推荐
ISO14443A读卡流程(作为示例参考)
罗克韦尔AB PLC RSLogix5000中定时器指令使用方法介绍
菲沃泰科创板上市:市值123亿 宗坚赵静艳夫妇身价76亿
暴力破解ssh/rdp/mysql/smb服务
leetcode二叉树系列(二叉搜索树篇)
Since his 97, I roll but he...
sync-diff-inspector 使用实践
继承和static关键字
ps抠图怎么抠出来,自学ps软件photoshop2022,ps怎么抠出想要的部分-笔记记录
2022 Cloud Native Computing代表厂商 | 灵雀云第三次入选Gartner中国ICT技术成熟度曲线报告
After four years of outsourcing, the autumn recruits finally landed
TiDB升级与案例分享(TiDB v4.0.1 → v5.4.1)
How Oracle for current library or certain library data on the same server number?
MindSpore:图算融合报错
JSP基本语法
【云驻共创】HCSD 大咖直播–就业指南
TCP的四次挥手
MindSpore:MindSpore GPU版本安装问题
cannot import name 'import_string' from 'werkzeug' [bug solution]
MATLAB绘图总结









