Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pie_slicer_demo.py ZZZ
- import appuifw, e32, graphics, key_codes, time
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- canvas = appuifw.Canvas(redraw_callback=draw)
- appuifw.app.directional_pad=False
- appuifw.app.orientation='portrait'
- appuifw.app.screen='large'
- appuifw.app.body=canvas
- w,h = canvas.size
- img=graphics.Image.new((w,h))
- #
- def up_event(event):
- cv.up=-1
- def dn_event(event):
- cv.up=0
- #
- def mv_event(event):
- cv.x=event[0]
- cv.y=event[1]
- cv.xy=cv.x/360,cv.y/yy2
- if time.time() > cv.up:
- exec ('s.'+cv.val+'+='+str(incr[cv.xy[1]]))
- cv.up=time.time()+0.5
- x_scr=360
- def full_bind():
- canvas.bind(key_codes.EButton1Up, up_event, ((0,0), (x_scr,720)))
- canvas.bind(key_codes.EButton1Down, dn_event, ((0,0), (x_scr,720)))
- canvas.bind(key_codes.EDrag, mv_event, ((0,0), (x_scr,720)))
- full_bind()
- def radian(d):
- return d*3.14/180.0
- class sval:
- x,y=20,60; rx,ry=90,180
- x2=y2=300
- xyt=rxy=0
- xyz=0,0,0
- up=-1
- t=0
- xy=0,0
- val='rx'
- s=sval()
- def gbr():
- plots=(s.x, s.y, s.x+s.x2+s.xyt, s.y+s.y2+s.xyt)
- img.pieslice(plots, radian(180-s.rx+s.rxy),radian(180-s.ry+s.rxy), outline=0xfff,fill=0x00ff00,width=10)
- img.text((10,20),u''+str(plots),0xffffff)
- img.text((10,40),u''+str((s.rx+s.rxy,+s.ry+s.rxy)),0xffffff)
- #
- def ruler():
- yy=0
- img.rectangle(((350-6,0), (358+2,640)), fill=(128,128,0))
- img.rectangle(((350,0), (358,640)), fill=(0,0,0))
- for ssVyy in xrange(0,9,2):
- yy=yy2*ssVyy+2
- img.rectangle(((350,yy), (358,yy+yy2)), fill=(255,255,255))
- #
- def z_tools():
- index=appuifw.popup_menu(tools,u'*** Select Tool ***')
- cv.val=tool_val[index]
- def clear_screen():
- img.clear()
- appuifw.note(u'Clear text on screen','info')
- #
- appuifw.app.menu=[(u'Select Tool',z_tools),(u'clear screen',clear_screen)]
- tools=[u'x move',u'y move',u'x scale',u'y scale',u'x+y scale',u'slice',u'rotate']
- tool_val=u'x y x2 y2 rx ry xyt rxy'.split()
- tools=tool_val
- class cvs:
- x=360
- y=0
- xy=0,4
- up=-1
- val='rx'
- cv=cvs()
- lg_scr = 576
- sVy = 9.0/lg_scr
- incr=[30,10,5,1,0,-1,-5,-10,-30]
- yy2=lg_scr/9
- run=1
- def quit():
- global run
- run=0
- appuifw.app.exit_key_handler=quit
- while run:
- if cv.x > 300:
- img.clear(0x3b3b3b)
- gbr()
- ruler()
- draw(())
- cv.x=0
- e32.ao_sleep(0.05)
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement