Advertisement
here2share

# star_polygon_demo.py

Jan 9th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # star_polygon_demo.py -- Note: the points are rounded
  2.  
  3. import appuifw, e32, graphics
  4.  
  5. def draw(rect):
  6.     try: canvas.blit(img)
  7.     except: pass
  8.  
  9. canvas = appuifw.Canvas(redraw_callback=draw)
  10. appuifw.app.directional_pad=False
  11. appuifw.app.orientation='portrait'
  12. appuifw.app.screen='large'
  13. appuifw.app.body=canvas
  14. w,h = canvas.size
  15. img=graphics.Image.new((w,h))
  16.  
  17. def star_5pt(x,y,s):
  18.     a,b,c,d,e,f,g,h,j,k,m,n,p = 0,180,294,476,250,192,308,500,340,402,357,96,157
  19.     plot_xy = [(a,b),(f,b),(e,a),(g,b),(h,b),(j,c),(k,d),(e,m),(n,d),(p,c)]
  20.     nova=[]
  21.     for xy in plot_xy:
  22.         xy = (xy[0]*0.002)*s+x,(xy[1]*0.002)*s+y
  23.         nova.append(xy)
  24.     return nova
  25.  
  26. star = star_5pt(30,60,300)
  27.  
  28. img.clear((0,0,0))
  29. img.polygon((star), outline=(0,255,0), width=10, fill=(255,255,0))
  30. draw(())
  31.  
  32. lock = e32.Ao_lock()
  33. appuifw.app.exit_key_handler = lambda:lock.signal()
  34. lock.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement