composite

How to clear the canvas for redrawing

泪湿孤枕 提交于 2019-11-25 22:56:56
问题 After experimenting with composite operations and drawing images on the canvas I\'m now trying to remove images and compositing. How do I do this? I need to clear the canvas for redrawing other images; this can go on for a while so I don\'t think drawing a new rectangle every time will be the most efficient option. 回答1: const context = canvas.getContext('2d'); context.clearRect(0, 0, canvas.width, canvas.height); 回答2: Use: context.clearRect(0, 0, canvas.width, canvas.height); This is the