Categories: S60 | Python | Code Examples
This page was last modified 19:46, 29 March 2007.
A simple random rectangle demo
From Forum Nokia Wiki
This example has been modified from The Mobile technology group example : rectangle.py
# random rectangle 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()
Here's a variation : It bounces a rectangle round the screen leaving a trail in different colors.
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 dy = 1 dx = 1 x1 = 10 y1 = 10 while running: x1 = x1 + dx y1 = y1 + dy x2 = x1 + 10 y2 = y1 + 10 if (x1 < 1): dx = -1 * dx if (y1 < 1): dy = -1 * dy if (x1 > res_x - 15): dx = -1 * dx if (y1 > res_y - 15): dy = -1 * dy color = randrange(0xffffff) canvas.rectangle((x1, y1, x2, y2), fill=color) e32.ao_yield()
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to change the color of the Highlight item in the listbox | RaveendraB | Symbian User Interface | 8 | 2008-02-28 17:49 |
| Getting CAknDialog to fill the app client rectangle | cagri00 | Symbian User Interface | 6 | 2008-04-14 10:02 |
| Help me with this error | kapot | Mobile Java General | 1 | 2002-10-10 06:29 |
| version 0.1 of Game demonstrating engine ready! | aehrath | General Symbian C++ | 2 | 2003-10-28 05:44 |
| symbian os Demo/Evaluation pack | karthikbalaguru | General Symbian C++ | 1 | 2004-09-23 14:49 |
