Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # s60_juggle.py -- with elseif comprehension
- from math import sin,cos,pi
- from random import randint
- from appuifw import app,Canvas
- from graphics import Image
- from e32 import ao_sleep
- running = 1
- def quit():
- global running
- running = 0
- app.exit_key_handler = quit
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- img = None
- app.screen = 'large'
- app.orientation = 'portrait'
- app.directional_pad = False
- app.body = canvas = Canvas(redraw_callback=draw)
- X, Y = canvas.size
- img=Image.new((X,Y))
- sx,sy,sxy=X/2,Y/2,X/5.0
- def radian(d):
- return (float(d)*pi)/180.0
- def plot():
- img.clear(0)
- for agl in cirx:
- rad=radian(agl*30)
- rgb=tuple([randint(60,256) for x in "***"])
- xp=cos(rad)*sxy-sin(rad)*sxy
- yp=sin(rad)*sxy+cos(rad)*sxy
- img.point((sx-xp,sy-yp),rgb,width=50)
- draw(())
- ao_sleep(0.08)
- cirx=[0,20,40]
- while running:
- cirx=tuple([1 if agl>59 else agl+1 for agl in cirx]) # <<< elseif comprehension
- plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement