# Import a library of functions called 'pygame'
from pygame import *
# Initialize the game engine
init()
# Open a window
size=(400,300)
screen=display.set_mode(size)
display.set_caption("Example code for the draw module")
# Initialize variables
done=False
black = ( 0, 0, 0)
white = (255,255,255)
blue = ( 0, 0,255)
green = ( 0,255, 0)
red = (255, 0, 0)
pi=3.141592653
#Loop until the user clicks the close button.
clock = time.Clock()
while not done:
for my_event in event.get(): # User did something
if my_event.type == QUIT: # If user clicked close
done=True # Flag that we are done so we exit this loop
# Clear the screen
screen.fill(white)
# Draw on the screen a green line from (0,0) to (50,75)
# 5 pixels wide.
draw.line(screen,green,[0,0],[50,75],5)
# Draw a rectangle outline
draw.rect(screen,black,[75,10,50,20],2)
# Draw a solid rectangle
draw.rect(screen,black,[150,10,50,20])
# Draw an ellipse outline, using a rectangle as the outside boundaries
draw.ellipse(screen,red,[225,10,50,20],2)
# Draw an solid ellipse, using a rectangle as the outside boundaries
draw.ellipse(screen,red,[300,10,50,20])
# This draws a triangle using the polygon command
draw.polygon(screen,black,[[100,100],[0,200],[200,200]],5)
# Draw an arc as part of an ellipse.
# Use radians to determine what angle to draw.
draw.arc(screen,black,[210,75,150,125], 0, pi/2, 2)
draw.arc(screen,green,[210,75,150,125], pi/2, pi, 2)
draw.arc(screen,blue, [210,75,150,125], pi,3*pi/2, 2)
draw.arc(screen,red, [210,75,150,125],3*pi/2, 2*pi, 2)
# Go ahead and update the screen with what we've drawn.
display.flip()
# This limits the while loop to a max of 10 times per second.
# Leave this out and we will use all CPU we can.
clock.tick(60)
# Be IDLE friendly
quit()