CS案例之Python Gui Drawing Clouds and Trees circles
当前位置:以往案例 > >CS案例之Python Gui Drawing Clouds and Trees circles
2018-01-21

EECS 12 project 4 (due 6pm, July 20)

Summer 2018


In this project, you are to complete a program to do the following tasks:


1. A function to draw two clouds in front of the mountains has been given. draw_cloud (win, x1, x2, y1, y2) returns a list of circles which form a cloud at the given positions. You should use it to create clouds when the program starts.

a. It will draw a cloud on window win by drawing several circles at different positions.

b. Using a loop statement, it randomly produces a point (Point(x, y)) in each iteration as the center of the circle to draw a circle with radius of 2 and append that circle to a list.

c. x1, x2, y1, y2 are coordinates on the left side and right side of the sky.

d. The function will return a list of all circles

2. Implement a function to draw a tree on the green part of the window

draw_tree (p1, p2)
a. Ask user to click two points (p1 and p2) to draw the brown tree trunk.

b. Based on the tree trunk, draw a green circle as the tree body:

– The center point of the circle is defined by below:image.png



– The radius of the circle is 1.2 times the tree trunk width.

– Draw the circle with a symmetric shape for tree.

3. Display the “Views”, “Wind”, “Exit” buttons. When the user clicks on

· the “View” button: the colors should change in sequence, the sky color to “deep sky blue”, the sun color to “dark orange”, and clouds color to “light gray”; after 1 second, the sky color should change to “navy”, clouds color



to “gray”, and sun should disappear; then after 1 second, the sky color and the sun color should change back to default colors.

· the “Winds” button, the two clouds should move horizontally to the right 10 times, just like the wind blows them to the right. Each time it moves x coordinate by 0.4. It sleeps for 0.1 second between moves.

· the “Exit” button, your program should close the window and stop.

Example:
1. Draw two clouds on the left and right sides of the sky.

image.png


2. Ask user for two points (p1 and p2) to draw the tree trunk, and based on the width of the tree trunk, draw the green tree body.

image.png

3. Display three buttons on the left side of the window, Views, Wind and Exit.

image.png



4. Clicking the Views button will make changes on the scene:

Morning scene:
image.png

Afternoon scene:

image.png


Evening scene:

image.png


5. Clicking the Wind button will blow the clouds to the right:

image.png

Grading Criteria
1. 15 points for correctly creating a graphics window and the buttons on it.

2. 25 points for correctly drawing the tree.

3. 25 points for correctly showing the views when “Views” clicked.

4. 25 points for correctly moving the clouds when “Wind” clicked.

5. 10 points for including comments in your program and correctly displaying user messages on the window during program execution.

Submission:

Submit before 6pm, July 20 (Friday) to the Canvas. Submit only the Python source file with the name of “ID-hw4.py”.


在线提交订单