Is there any margin between your canvas and your browser window? Any bit of spacing can throw off your mouse position, so you'd need to add that bit of offset to your equation when detecting for coordinates.
You can get an element's offset with
Want to participate?
Create a free Chris Courses account to begin