Advertisement
here2share

# color_touch.py

Dec 11th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # color_touch.py
  2.  
  3. import appuifw
  4. import graphics
  5. import key_codes
  6.  
  7. dotykxy=(0,0)
  8. kolorxy=(0,0,0)
  9.  
  10. def odswiezanie(rect):
  11.     global dotykxy
  12.     global kolorxy
  13.     img=graphics.Image.new(cv.size)
  14.     img.clear(0x000000)
  15.     img.ellipse(((60-50,100),(60+50,200)),(255,0,0),(255,0,0))
  16.     img.ellipse(((180-50,100),(180+50,200)),(0,255,0),(0,255,0))
  17.     img.ellipse(((300-50,100),(300+50,200)),(0,0,255),(0,0,255))
  18.     img.ellipse(((60-50,250),(60+50,350)),(0,255,255),(0,255,255))
  19.     img.ellipse(((180-50,250),(180+50,350)),(255,0,255),(255,0,255))
  20.     img.ellipse(((300-50,250),(300+50,350)),(255,255,0),(255,255,0))
  21.    
  22.     kolorxy=img.getpixel(dotykxy)[0]
  23.     img.text((30,30),u'X:'+unicode(dotykxy[0]),(255,255,255))
  24.     img.text((80,30),u'Y:'+unicode(dotykxy[1]),(255,255,255))
  25.     img.text((180,30),u'R:'+unicode(kolorxy[0]),(255,255,255))
  26.     img.text((230,30),u'G:'+unicode(kolorxy[1]),(255,255,255))
  27.     img.text((280,30),u'B:'+unicode(kolorxy[2]),(255,255,255))
  28.     cv.blit(img,(0,0))
  29.  
  30. def ekran():
  31.     appuifw.e32.reset_inactivity()
  32.     timer.after(1,ekran)
  33.  
  34. def dotyk(pos):
  35.     global dotykxy
  36.     dotykxy=pos
  37.     odswiezanie(cv.size)
  38.  
  39. def koniec():
  40.     app_lock.signal()
  41.  
  42. appuifw.app.directional_pad=False
  43. cv=appuifw.Canvas(redraw_callback=odswiezanie)
  44. appuifw.app.body=cv
  45. appuifw.app.exit_key_handler=koniec
  46. cv.bind(key_codes.EButton1Down,dotyk)
  47.  
  48. timer=appuifw.e32.Ao_timer()
  49. timer.after(1,ekran)
  50.  
  51. app_lock=appuifw.e32.Ao_lock()
  52. app_lock.wait()
  53. timer.cancel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement