Assignment3.py - Michelle Gong Section 03 This program demonstrates drawing shapes on a canvas using Gui tools This program is not interactive Required

# Assignment3.py - Michelle Gong Section 03 This program...

• Homework Help
• 4

This preview shows page 1 - 2 out of 4 pages.

# Michelle Gong # Section 03 # This program demonstrates drawing shapes on a canvas using Gui tools. # This program is not interactive. # 10/17/19 # Required import statement for Gui tools import Gui3 # Named Constants CANVAS_WIDTH = 900 CANVAS_HEIGHT = 800 # Function Definition Section # Draws one tree. The first two required parameters base_x and base_y # specify the location of a point at the center of the bottom edge # of the tree trunk. The third parameter is the height of the tree. # The first three parameters have units of pixels. # The last parameter is optional and specifies the color of the # crown of the tree; it must be a string value containing a legal # TK symbolic color (refer to the comment at the end for more info) # or a hexadecimal RGB color code formatted like this: '#34FA90'. def draw_simple_tree(base_x, base_y, height, color='darkgreen'): # draw trunk trunk_x1 = base_x - height * 0.05 trunk_x2 = base_x + height * 0.05 trunk_y1 = base_y trunk_y2 = base_y + height * 0.5 canvas.rectangle([[trunk_x1, trunk_y1], [trunk_x2, trunk_y2]], \ fill='brown', width = 0) # draw crown # the polygon has 3 points, peak, lower left (LL), and lower right (LR) LL_x = base_x - height * 0.2 LR_x = base_x + height * 0.2 L_y = base_y + height * 0.3 canvas.polygon([[base_x, base_y + height], [LL_x, L_y], [LR_x, L_y]], \ fill=color, width=0) # Draws a cluster of three trees. The parameters x and y specify # the location of a point at the center of the bottom edge # of the tree trunk of the largest tree in the cluster.

#### You've reached the end of your free preview.

Want to read all 4 pages?

• Spring '16
• goldner barbara

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern