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 th
context.clearRect ( x , y , w , h );
as suggested by @Pentium10 but IE9 seems to completely ignore this instruction.canvas.width = canvas.width;
but it doesn't clear lines, just shapes, pictures and other objects unless you also use @John Allsopp's solution of first changing the width.So if you have a canvas and context created like this:
var canvas = document.getElementById('my-canvas');
var context = canvas.getContext('2d');
You can use a method like this:
function clearCanvas(context, canvas) {
context.clearRect(0, 0, canvas.width, canvas.height);
var w = canvas.width;
canvas.width = 1;
canvas.width = w;
}