This morning's prompt is 'pork chop'.
const canvas = document.getElementById('myCanvas');const ctx = canvas.getContext('2d');canvas.addEventListener('click', function(event) { const rect = canvas.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; // Do something with the click coordinates console.log('Click at:', x, y); // Example: Draw a circle at the click position ctx.beginPath(); ctx.arc(x, y, 10, 0, 2 * Math.PI); ctx.stroke();});
No comments:
Post a Comment