Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # touch_drawing.py
- import appuifw, e32, graphics, key_codes, time
- def cv(): pass
- cv.x=0
- cv.y=0
- cv.color=(255,0,0)
- thickness=5
- cv.jot=-10,-10,-10,-10
- cv.t=0
- if not appuifw.touch_enabled():
- appuifw.note(u"This application only works on devices that support touch input")
- def e_callback(event):
- x=event['pos'][0]
- y=event['pos'][1]
- if not event['type'] in [key_codes.EButton1Up, key_codes.EButton1Down, key_codes.EDrag]:
- return
- if event['type'] == key_codes.EButton1Down:
- cv.x=x
- cv.y=y
- elif event['type'] == key_codes.EDrag:
- if cv.t < time.time():
- cv.t=time.time()+0.04
- cv.jot=(x, y, cv.x, cv.y)
- cv.x=x
- cv.y=y
- draw(())
- def draw(rect):
- canvas.line(cv.jot, outline=cv.color, width=thickness, fill=cv.color)
- def quit():
- script_lock.signal()
- canvas=appuifw.Canvas(event_callback=e_callback, 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))
- canvas.clear()
- draw(())
- print 12345
- appuifw.app.exit_key_handler=quit
- script_lock=e32.Ao_lock()
- script_lock.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement