photon/demo/random_rectangles.py

25 lines
971 B
Python
Raw Normal View History

2011-03-29 01:23:13 +00:00
#!/usr/bin/env python
2011-03-16 03:26:07 +00:00
import random
2011-03-29 00:54:04 +00:00
from csdl.video import Rect
from demo_utils import simple_timed_loop
2011-03-16 03:26:07 +00:00
2011-03-29 00:54:04 +00:00
def draw(window):
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()
2011-03-16 03:26:07 +00:00
2011-03-29 00:54:04 +00:00
if __name__ == '__main__':
simple_timed_loop(draw)