skip to Main Content

Javascript – HTML canvas: additional stroke after restore

Consider the following piece of code (test it yourself): function draw() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.arc(75, 75, 50, 0, Math.PI * 2, true); // Outer circle ctx.stroke(); ctx.moveTo(75, 75); ctx.save(); ctx.setLineDash([3, 3]); ctx.lineTo(90, 90);…

VIEW QUESTION

HTML Canvas "onmousedown" event and "mousedown" listener not firing

I have an HTML page with a canvas in the body defined as so: <!DOCTYPE html> <html> <head> <script defer src="./js/canvas.js"></script> <link rel="stylesheet" href="./css/canvas.css"> </head> <body> <canvas id="pinboard"></canvas> </body> </html> In canvas.js I've written: var canvas = document.getElementById("pinboard"); canvas.addEventListener("mousedown", function…

VIEW QUESTION
Back To Top
Search