''' graphics2.py Jeff Ondich, 11 October 2018 Started in Pascal on 1/25/95 Ported to C++, Java, and Python Adapted to Python 3 by Jed Yang in 2016 1. Try it. 2. Identify which corner of the polygon has which coordinates as listed in the source code. 3. Redesign the polygon to be a triangle or a rectangle. Can you do a regular hexagon? 4. What is the default background color of a GraphWin object? ''' from graphics import * def main(): window = GraphWin('Polygon demo', 600, 500) polygon = Polygon(Point(200, 100), Point(400, 100), Point(500, 200), Point(400, 300), Point(200, 200)) polygon_color = color_rgb(255, 0, 0) polygon.setOutline(polygon_color) # Some come colors have pre-defined names so you don't have to mix RGB values # with color_rgb(). But then you have less control over the resulting color. polygon_fill_color = 'yellow' polygon.setFill(polygon_fill_color) # What is the difference between .setOutline() and .setFill()? polygon.draw(window) # Can you .draw() first and then .setFill() later? # Wait for user input. print('Hit any key to quit') keyResponse = window.getKey() print('You hit', keyResponse) # Which window needs input focus for this to work? Why? # Which keys work? main()