Make sure all programs are saved to your cs21/labs/06
directory. Files outside this directory will not be graded.
$ update21
$ cd ~/cs21/labs/06/
width
and height
for the width and height of the GraphWin
object. Then specify positions and lengths as fractions of the width or height. To test this, change width
and height
and make sure everything scales nicely.y
you go down, not up, the graphics window.Write a program, scene.py
, that draws a scene and includes some animation. You can mimic the beach scene shown below or imagine a scene of your own invention.
Your scene should include:
Circle
, Rectangle
, Polygon
, Line
, and Oval
.Text
object.main()
.There are many different ways to satisfy the requirements. This video shows one of the many possible solutions.
Notice how the user's mouse clicks determine where elements of the beach scene are positioned. In some cases (positioning the horizon and the sand) we only use the y-coordinate of the point that was clicked. We used the setText()
method for Text
objects to update the instructions. To animate the sunset, we repeatedly performed the following steps:
move()
method.sleep(seconds)
function. Import the time
library to get access to this function.Write a program, connect.py
, that lets its users draw a polygon in a graphics window.
Polygon
objects in the Zelle graphics library are created from a list of Point
objects. Each time the user clicks above the gray bar, the corresponding point should be drawn to the window and added to the list of points that will ultimately be used to create the polygon. When the user clicks on the gray bar, the polygon should be drawn to the window and filled with a randomly-generated color.
Define (and use) a separate function that generates a random color. This function should itself make use of the color_rgb
function. You are encouraged, but not required, to write additional functions as you see fit.
Note that if the sides of the polygon cross, a portion of the background will show through, as in the second example from the video. There is still only one Polygon
object in the program.
Once you are satisfied with your scene.py
and connect.py
programs, fill out the questionnaire in QUESTIONS-06.txt
. Then run handin21
a final time to make sure we have access to the most recent versions of your files.