I see if sting touch a circle

Click and drag to draw a line, line gets red if touched

Move on, get a better browser

Credit

Me and this guy, pretty cool number tutor. Funny man, always happy even when I always get answers wrong and seem to watch YouTube during class

Oh yeah and my parents, for giving him money

How work?

When you draw line, computer find the linear equation version of line. Computer play "pretend you're in the middle of the universe" and draw a perpidicular line that crosses your mouse point. Then grabs the intersection point of the perpindicylar line and see if the point is close to your circle mouse to bump.

I don't want to decipher the Rosseta Stone that is your code, to find out how this really works

No living human would actually want to know and read through all this, but I like explaining things and put some meaningful comments in my github commit.

Uh, so I don't actually need to "simulate" two perpindicular lines, that's just the concept of how a human would do it.

For the computer, I just throw in an equation to immediately get the dot, whose equation is built upon the concept

Here equation for finding, imma gonna call him Billy:
X=K*-M/(M^2 + 1) and Y = K/(M^2 + 1)
I'm using this linear equation: y = mx + k

Before I got anywhere close to making the above, I was Google searching "How to solve two linear equations in Javascript" and almost made a Stack Overflow question, which I clearly doubted doing because it seemed more like a math problem and might lose me some reputation.

Anyways, back to how computer do it, it substracts the coordinates of the two points, that make up the line, by the coordinates of the mouse (X - MouseX, Y - MouseY). So relatively, where the mouse used to be is now located in the middle.
Read ylu\\\

Then I use the new cooridnates and shoot Billy at it and grabs the intersection point's coordinates. Yes I knoe the image above is ahead of me.

All there's left to do is to grab the sum of the point's coordinates and the mouse's, which I then decided to visually show it when you click the "Debug: Off" (Or "Debug: On", if you already turned it on);

And nail Pythagoras to get the distance from the point to the mouse to see if it's close enough to be colliding.

The end

Assuming you know how to get m and k, but they teach you that in 6-7th grade

Log: