当前位置:网站首页>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
);
边栏推荐
猜你喜欢

I am 37 this year, and I was rushed by a big factory to...

蜜芽CEO刘楠:垂直电商黄金时代已落幕 坚定转型品牌之路

【正点原子STM32连载】第三章 开发环境搭建 摘自【正点原子】MiniPro STM32H750 开发指南_V1.1

MySQL binlog都有哪些模式?
![No module named 'flask_misaka' has been resolved [BUG solution]](/img/cc/e379d23a41330d2335dd192e16e821.png)
No module named 'flask_misaka' has been resolved [BUG solution]

Apache APISIX 2.15 版本发布,为插件增加更多灵活性

思想茶叶蛋 (Jul 31,2022)| 元宇宙(Metaverse)下了一枚什么样的蛋

Fiddler(二)-手机抓包502错误解决方法
![Detailed explanation of MSTP protocol configuration on Layer 3 switches [Huawei eNSP experiment]](/img/97/6c3662ef36b02bc42eec95abaa6bc5.png)
Detailed explanation of MSTP protocol configuration on Layer 3 switches [Huawei eNSP experiment]

渗透——信息收集
随机推荐
Detailed explanation of telnet remote login aaa mode [Huawei eNSP]
Qt:小的任务管理器(task)
张朝阳对话俞敏洪:谈宇宙、谈焦虑、谈创业、谈退休、谈人生
数据万象内容审核 — 共建安全互联网,专项开展“清朗”直播整治行动
Four common methods of network attacks and their protection
LVGL's multi-language conversion tool -- a good assistant for font settings
Anton Paar安东帕密度计比重计维修DMA35性能参数
华为od项目
sync-diff-inspector 使用实践
四大网络攻击常见手段及防护
架构设计杂谈
ps抠图怎么抠出来,自学ps软件photoshop2022,ps怎么抠出想要的部分-笔记记录
Anton Paar Anton Paar Density Meter Hydrometer Repair DMA35 Performance Parameters
GBsae 8 c database using an error, how to do?
cannot import name ‘import_string‘ from ‘werkzeug‘【bug解决】
【c】操作符详解(二)
暴力破解-破解 Apache BASIC 认证
开源一夏 | 查询分页不只有limit,这四种分页方法值得掌握
LVGL的多语言转换工具--字体设置的好助手
TiFlash 源码阅读(五) DeltaTree 存储引擎设计及实现分析 - Part 2