photon/demo/random_rectangles.py
2011-03-27 01:46:06 -04:00

36 lines
1.2 KiB
Python

from csdl import init, INIT
from csdl.video import Window, Rect
from csdl.events import EventType, poll_event
import random
import time
def main():
init(INIT.EVERYTHING)
window = Window('test', 100, 100, 512, 512, 0)
while True:
while True:
event = poll_event()
if not event:
break
else:
print event.type
window.renderer.set_draw_color(0,0,0,255)
window.renderer.clear()
window.renderer.set_draw_color(255,0,0,255)
for i in xrange(20):
window.renderer.set_draw_color(random.randint(0,255),
random.randint(0,255),
random.randint(0,255))
r = Rect(random.randint(0,512), random.randint(0, 512),
random.randint(0,300), random.randint(0, 300))
s = Rect(random.randint(0,512), random.randint(0, 512),
random.randint(0,300), random.randint(0, 300))
t = Rect(random.randint(0,512), random.randint(0, 512),
random.randint(0,300), random.randint(0, 300))
window.renderer.fill_rects([r,s,t])
window.renderer.present()
time.sleep(.001)
main()