In a previous lesson, you learned how to use the mouse() function to
read the $(x,y)$ coordinate of a mouse click. Let's use this function and your newly found
knowledge about how to draw lines to create a simple
drawing program.
Since a line requires two points to draw between, say $(x_1,y_1)$ and $(x_2,y_2)$, let's write
some code that makes two calls to the mouse() function. When run, you are to click on the
drawing twice, once for each mouse() function call. After the second click, a line should
appear between your two click points.
Now you try. Run this code several times, clicking on two points. Create a simple drawing!
Type your code here:
See your results here:
This code will run, but will not do anything. After the two mouse() lines, you need to put
in a statement to draw a line between (x1,y1) and (x2,y2). If you get this done,
then two clicks on the output screen will result in a line drawn between the two click points
Can you do it?
Share your code
Show a friend, family member, or teacher what you've done!