rect undraw(return poly make sure you understandfollow this code throughimagining three mouse clicks inside rect and then one click outside of rect compare the steps to the ones in the concrete sequence written out above and see that the match (aside from the last canceling undraw and draw of polythis function is illustrated in the example program makepoly py other than standard graphics example codethe main program containsrect rectangle(point( )point( )poly polyhere(rect winpoly setfill('green'rect rectangle(point( )point( )poly polyhere(rect winpoly setoutline('orange'as you can seethe returned polygons are used to make color changesjust as an illustration in earlier animation examples while loop would also have been useful rather than continuing the animation fixed number of timesit would be nice for the user to indicate by mouse click when she has watched long enough thus far the only way to use the mouse has been with getmouse(this is not going to work in an animationbecause the computer stops and waits for click with getmouse()whereas the animation should continue until the click in full-fledged graphical systems that respond to eventsthis is no problem zelle' graphics is built on top of capable event-driven systemand in factall mouse clicks are registeredeven outside calls to getmouse(as an examplerun example program randomcircleswhile py be sure to follow the prompt saying to click to start and to end aside from the promptsthe difference from the previous randomcircles py program is the replacement of the original simple repeat loop heading for in range( )by the following initialization and while loop headingwhile win checkmouse(=none#newthe graphics module remembers the last mouse clickwhether or not it occurred during call to getmouse( way to check if the mouse has been clicked since the last call to getmouse(is checkmouse(it does not wait for the mouse as in getmouse(instead it returns the remembered mouse click the most recent mouse click in the pastunless there has been no mouse click since the last call to getmouse or checkmouse in that case checkmouse(returns none (the special object used to indicate the lack of regular objectthe checkmouse method allows for loop that does not stop while waiting for mouse clickbut goes on until the heading test detects that the mouse was clicked similar elaboration can be made for the other examples of animationlike bounce py in bouncewhile py modified bounce py to have while loop in place of the for-loop repeating times run it the only slight added modification here was that win was not originally parameter to bounceinboxso included it look at the source code for bouncewhile pywith the few changes marked new in bounce py also made more interesting change to the initializationso the initial direction and speed of the mouse are determined graphically by the userwith mouse click try example program bounce py the program includes new utility function to help determine the initial (dxdyfor the animation this is done by calculating the move necessary to go from one point (where the ball is in this programto another (specified by user' mouse click in this program more on flow of control