jeudi 25 janvier 2018

Effacer canvas

<button onclick="myRect()">Rect</button> <button onclick="myClear()">Go</button></br></br>
<canvas id="myCanvas3" width="500" height="500" style="border:1px solid #c0c0c0;">Your browser does not support the canvas element.</canvas>

<script>

var canvas = document.getElementById("myCanvas3");
var ctx = canvas.getContext("2d");

function myRect() {
ctx.beginPath();
ctx.fillStyle = 'royalblue';
ctx.rect(200,200,100,100);
ctx.fill();
}

function myClear() {
void ctx.clearRect(0, 0, 500, 500);
}


</script>