La mouse se déplace
function drawShape(){
var lastX = 0, lastY = 0, count = 0;
var r = Math.floor(Math.random()*255)+70;
var g = Math.floor(Math.random()*255)+70;
var b = Math.floor(Math.random()*255)+70;
timer1 = setInterval(drawLoop, 16);
function drawLines(x, y)
{
ctx.lineWidth = 40;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(lastX, lastY);
ctx.lineTo(x, y);
ctx.strokeStyle = "rgba(" + r + "," + g + "," + b + ", 1)";
ctx.stroke();
}
function drawLoop()
{
// Clear first
ctx.fillStyle = "rgba(0,0,0,0.05)";
ctx.fillRect(0, 0, WIDTH, HEIGHT);
// Draw lines
drawLines(currentX, currentY);
// Change up color
if (count++ > 50)
{
count = 0;
r = Math.floor(Math.random() * 255) + 70;
g = Math.floor(Math.random() * 255) + 70;
b = Math.floor(Math.random() * 255) + 70;
}
// Update coordinates
lastX = currentX;
lastY = currentY;
}