HTML5 Canvas 是否支持双缓冲?
htmljavascriptprogramming scripts更新于 2025/3/13 12:28:17
要在画布上进行双缓冲,请创建第二个画布元素并绘制到该元素上。之后,使用 drawImage() 方法将图像绘制到第一个画布上,
// 画布元素
var canvas1 = document.getElementById('canvas');
var context1 = canvas1.getContext('2d');
// 缓冲画布
var canvas2 = document.createElement('canvas');
canvas2.width = 250;
canvas2.height =250;
var context2 = canvas2.getContext('2d');
// 在画布上创建
context2.beginPath();
context2.moveTo(10,10);
context2.lineTo(10,30);
context2.stroke();
//渲染缓冲画布
context1.drawImage(canvas2, 0, 0);
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

