I want to create a series of interactive areas in a canvas. The number of areas are dynamic so I cannot hardcode the coordinates.
Im adding the areas to a click event handler like this...
$('#FootprintCV').click(function (e) {
var clickedX = e.pageX - this.offsetLeft;
var clickedY = e.pageY - this.offsetTop;
if (clickedX < area1.right && clickedX > area1.left && clickedY > area1.top && clickedY < area1.bottom) {
console.log('Area1 clicked at X: ' + clickedX + " Y:" + clickedY);
}
}
});