Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # color_touch.py
- import appuifw
- import graphics
- import key_codes
- dotykxy=(0,0)
- kolorxy=(0,0,0)
- def odswiezanie(rect):
- global dotykxy
- global kolorxy
- img=graphics.Image.new(cv.size)
- img.clear(0x000000)
- img.ellipse(((60-50,100),(60+50,200)),(255,0,0),(255,0,0))
- img.ellipse(((180-50,100),(180+50,200)),(0,255,0),(0,255,0))
- img.ellipse(((300-50,100),(300+50,200)),(0,0,255),(0,0,255))
- img.ellipse(((60-50,250),(60+50,350)),(0,255,255),(0,255,255))
- img.ellipse(((180-50,250),(180+50,350)),(255,0,255),(255,0,255))
- img.ellipse(((300-50,250),(300+50,350)),(255,255,0),(255,255,0))
- kolorxy=img.getpixel(dotykxy)[0]
- img.text((30,30),u'X:'+unicode(dotykxy[0]),(255,255,255))
- img.text((80,30),u'Y:'+unicode(dotykxy[1]),(255,255,255))
- img.text((180,30),u'R:'+unicode(kolorxy[0]),(255,255,255))
- img.text((230,30),u'G:'+unicode(kolorxy[1]),(255,255,255))
- img.text((280,30),u'B:'+unicode(kolorxy[2]),(255,255,255))
- cv.blit(img,(0,0))
- def ekran():
- appuifw.e32.reset_inactivity()
- timer.after(1,ekran)
- def dotyk(pos):
- global dotykxy
- dotykxy=pos
- odswiezanie(cv.size)
- def koniec():
- app_lock.signal()
- appuifw.app.directional_pad=False
- cv=appuifw.Canvas(redraw_callback=odswiezanie)
- appuifw.app.body=cv
- appuifw.app.exit_key_handler=koniec
- cv.bind(key_codes.EButton1Down,dotyk)
- timer=appuifw.e32.Ao_timer()
- timer.after(1,ekran)
- app_lock=appuifw.e32.Ao_lock()
- app_lock.wait()
- timer.cancel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement