# Lesson goal: Drawing circles with the mouse

Previous: Drawing lines with the mouse | Home | Next: The slope of a line

In a previous lesson, you learned how to use the mouse() function to draw lines between two mouse click positions. Let's keep going and see if can draw circles with the mouse. How about we'll use the first click as the center of the circle, and the second click as a point through which the circle should pass?

Remember that drawing a circle takes three numbers, as outlined in this lesson. The first two are the $(x,y)$ coordinate of the center of the circle. The third number is the radius of the circle. Since the second click position should be on the circle, the radius of the circle should be the distance between the two mouse-click points. Ah ha! A chance to use the distance formula.

# Now you try. Run this code several times, clicking on two points. Create a simple drawing!

This code will not run. You have to fix the d=sqrt( ) line to compute the distance between the two mouse-click points, $(x_1,y_1)$ and $(x_2,y_2)$. Next, you have to complete the circle( ) line to properly draw the circle centered at $(x_1,y_1)$ with a radius of $d$. Can you do it? Dismiss.
Show a friend, family member, or teacher what you've done!