By some starnge reason it does not work for me to do the
canvas.width = canvas.width;
here is my code:
function startDraw(){
document.getElementById('PaintArea').setAttribute('onmousemove', 'getMouse(event)');
}
function stopDraw(){
document.getElementById('PaintArea').setAttribute('onmousemove', '');
}
function Paint(){
var Size = document.getElementById('Size').value;
var Opacity = document.getElementById('opa').value;
var color = document.getElementById('color').value;
canvas = document.getElementById('PaintArea');
if(canvas.getContext){
var ctx = canvas.getContext('2d');
ctx.fillStyle = color;
ctx.globalAlpha = Opacity;
ctx.beginPath();
ctx.arc(musX-10, musY-10, Size, 0, Math.PI*2);
ctx.closePath();
ctx.fill();
}
}
function clear(){
canvas.width = canvas.width;
}
function getMouse(event) {
musY = event.clientY;
musX = event.clientX;
Paint();
}
button:
<button onclick="clear()">Clear</button>
in the chrome console it says : "document.clear() is deprecated. This method doesn't do anything."
i also have these global varables:
var musX;
var musY;
var canvas;