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!

Type your code here:


See your results here: