Calculating if the mouse is inside a circle is very easy. We just need to know the distance from the center of the circle to the mouse pointer, and if this distance is less than the radius of the circle, we are inside. The radius of the circle is the same as half the size of the circle.Calculating if the mouse is inside a square is a bit more tricky. We need to know four things. Is the mouse below the top border of the square? is the mouse above the bottom of the square? is it on the left side of the right side of the square? is is on the right side of the left border? If those four conditions are all true, then the mouse pointer is inside the square.
Learn creative programming using Processing, SuperCollider and other Free Software. Meant for people of all ages who are curious about what programming is. We focus on creating interesting visual and sound effects. More playing than theory.