-
Notifications
You must be signed in to change notification settings - Fork 0
/
CD_Scenario3.py
39 lines (37 loc) · 1.07 KB
/
CD_Scenario3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pygame
import sys
from pygame.locals import *
white = (255,255,255)
red = (255, 0, 0)
blue = (0, 0, 255)
green = (0, 255, 0)
black = (0, 0, 0)
yellow = (255, 255, 0)
frame = pygame.display.set_mode((200, 200)) #scaled by 10
pygame.display.set_caption('Trapezoidal decomposition')
frame.fill(white)
x = 0;
y = 0;
while True:
pygame.draw.line(frame,red,[40, 120], [100, 50],2)
pygame.draw.line(frame,red,[100, 50], [150, 120],2)
pygame.draw.line(frame,red,[40, 120], [100, 90],2)
pygame.draw.line(frame,red,[100, 90], [150, 120],2)
pygame.draw.rect(frame, white, [x, 0, 2, 200])
x = x + 0.001
pygame.draw.rect(frame, blue, [x, 0, 2, 200])
#print x
if(x > 40):
pygame.draw.rect(frame, yellow, [40, 0, 2, 200])
if(x > 100):
pygame.draw.rect(frame, yellow, [100, 0, 2, 50])
pygame.draw.rect(frame, yellow, [100, 90, 2, 200])
if(x >150):
pygame.draw.rect(frame, yellow, [150, 0, 2, 200])
#pygame.draw.Rect(frame,red,[200, 300], [450, 600],5)
for event in pygame.event.get():
print event
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()