# myArtwork.py # Written by Dave Musicant # Inspired by a lab from Jeff Ondich # This program opens up a graphics window, fills it with a black # background, and draws a purple rectangle on it. from graphics import * windowWidth = 500 windowHeight = 700 window = GraphWin('Hi there', windowWidth, windowHeight) window.setBackground('black') # If you want to mix your own colors, you can do so. The function # color_rgb takes takes three parameters, each of which are in the # range from 0 and 255, representing the amount of red, green, and # blue in the color. So (0,0,0) means no color (black), (255,0,255) # means a shade of purple, and (127,0.127) is darker purple, etc. brightPurple = color_rgb(240,0,240) # Draw a rectangle. More specifically, draw a rectangle with: a top # left corner of x = windowWidth/2, y = windowHeight/2, and a bottom # right corner of x = windowWidth-10, y = windowHeight-30. rectangle = Rectangle(Point(windowWidth/2,windowHeight/2), Point(windowWidth-10,windowHeight-30)) rectangle.setOutline(brightPurple) rectangle.draw(window) # Wait for user to admire the art before closing the window. raw_input('Hit Enter to close the window.') window.close()