Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Random rectangle demo (See related posts)

A good short demo for pys60.
# random rectangle
# modify from http://mtg.lcc.gatech.edu/class/rectangles.py

from appuifw import *
import e32
from random import randrange

running = 1
def quit():
	global running
	running = 0
app.exit_key_handler = quit

app.screen = 'large'
app.body = canvas = Canvas()
res_x, res_y = canvas.size

while running:
	x1 = randrange(res_x)
	x2 = randrange(x1, res_x)
	y1 = randrange(res_y)
	y2 = randrange(y1, res_y)
	color = randrange(0xffffff)
	canvas.rectangle((x1, y1, x2, y2), fill=color)
	e32.ao_yield()

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts