I've been tasked with this assignment:

In a graphics window, you are to draw an outdoor scene containing a house.
Your drawing should include at least the following shapes: three rectangles, two lines, one circle and one text label
Your picture should not be boring black and white. It should include at least three colors, tastefully distributed to bring your house to life.
Finally, it should have some interactive feature such that when a user clicks on your picture something changes (e.g. a color changes, a tree falls over, the sun rises, a door opens). The change only has to happen once.

I am stuck on one part, how to color in the roof. I used two lines to make the roof but I can't figure out how to fill the space between the two lines. Any idea how I would do this? I was thinking maybe a setFill with plots but I can't find any examples of what that should look like.

Roof = Line(Point(200,150), Point(305,15))
Roof2 = Line(Point(305,15), Point(420,150,))
Roof.draw(win)
Roof2.draw(win)

Screenshot_2019-02-16_15_03_37.png

Recommended Answers

All 2 Replies

This might be a hint:

'''zg_triangle1.py
using the Zelle graphics module (derived from Tkinter)
http://mcsp.wartburg.edu/zelle/python/graphics.py
'''

from graphics import *

def drawTrianglePatch(win, colour):
    # polygon goes back to starting point (80, 20)
    triangle = Polygon(Point(80,20),Point(180,60),Point(60,220))
    triangle.setFill(colour)
    triangle.draw(win)

w = 250
h = 250
win = GraphWin("triangle stuff", w, h)

colour = 'red'
drawTrianglePatch(win, colour)

# pause for click inside window, then exit
win.getMouse()
win.close()

The documentation for graphics.py is at
Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.