Advertisement
here2share

# s60_juggle.py -- with elseif comprehension

Jul 10th, 2016
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # s60_juggle.py -- with elseif comprehension
  2.  
  3. from math import sin,cos,pi
  4. from random import randint
  5.  
  6. from appuifw import app,Canvas
  7. from graphics import Image
  8. from e32 import ao_sleep
  9.  
  10. running = 1
  11. def quit():
  12.     global running
  13.     running = 0
  14. app.exit_key_handler = quit
  15.  
  16. def draw(rect):
  17.     try: canvas.blit(img)
  18.     except: pass
  19.  
  20. img = None
  21. app.screen = 'large'
  22. app.orientation = 'portrait'
  23. app.directional_pad = False
  24. app.body = canvas = Canvas(redraw_callback=draw)
  25. X, Y = canvas.size
  26. img=Image.new((X,Y))
  27.  
  28. sx,sy,sxy=X/2,Y/2,X/5.0
  29.  
  30. def radian(d):
  31.     return (float(d)*pi)/180.0
  32.  
  33. def plot():
  34.     img.clear(0)
  35.     for agl in cirx:
  36.         rad=radian(agl*30)
  37.         rgb=tuple([randint(60,256) for x in "***"])
  38.         xp=cos(rad)*sxy-sin(rad)*sxy
  39.         yp=sin(rad)*sxy+cos(rad)*sxy
  40.         img.point((sx-xp,sy-yp),rgb,width=50)
  41.     draw(())
  42.     ao_sleep(0.08)
  43.  
  44. cirx=[0,20,40]
  45. while running:
  46.     cirx=tuple([1 if agl>59 else agl+1 for agl in cirx]) # <<< elseif comprehension
  47.     plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement