Use context.clearRect(0, 0, canvas.width, canvas.height); and cache your image, do not reboot every time you update
UPDATE: I donβt know if this will work, itβs unverified and some time has passed since I used the canvas, but I will try it
var canvas = document.getElementById('progress'); var context = canvas.getContext('2d'); var img = new Image(); var imgLoaded = false; img.src = 'pizza.png'; img.onload = function(){ imgLoaded = true; } function drawProgress(degs){ context.save(); context.clearRect(0, 0, canvas.width, canvas.height); context.globalAlpha=1; context.beginPath(); context.arc(canvas.width/2,canvas.height/2, canvas.height/2, 0, degs * (-Math.PI/180), true); context.lineTo(canvas.width/2, canvas.height/2); context.clip(); if (imgLoaded) context.drawImage(img, 0, 0, canvas.width,canvas.width); context.restore(); }
TimCodes.NET
source share