Как в canvas при наведении на блок поменять курсор мыши?
Аналогичное в css cursor: pointer;
function drawBar(ctx, x, y, w, h, color = '#000', radius = 0) {
ctx.save();
if (radius > 0) {
ctx.arc(x, y, w, h, radius * Math.PI);
}
ctx.fillStyle = color;
ctx.fillRect(x, y, w, h);
ctx.restore();
}
let canvas = document.querySelector('canvas');
let ctx = canvas.getContext('2d');
canvas.style.width = canvas.offsetWidth +'px';
canvas.style.height = canvas.offsetHeight +'px';
canvas.width = canvas.offsetWidth * 2;
canvas.height = canvas.offsetHeight * 2;
drawBar(ctx, 40, 40, 160, 60, '#090', 5);
canvas {
width: 200px;
height: 100px;
border: 1px solid #000;
}
<canvas></canvas>