omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to use class touch ?

    Pythonista
    2
    6
    1029
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Raymond
      Raymond last edited by Raymond

      i dont know how to use Touch class..so i want simple example..
      i try this to learn..but its not work:

      import ui
      
      v = ui.load_view('main')
      t = ui.Touch
      v.present('sheet')
      
      
      
      while v.on_screen:
      	print(t.phase)
      
      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @Raymond last edited by cvp

        @Raymond see Sketch example in Pythonista examples.

        touch parameter of touch_xxx functions is an ui.Touch

        1 Reply Last reply Reply Quote 0
        • Raymond
          Raymond last edited by

          What?!! There is no sketch example in pythonista site !

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @Raymond last edited by cvp

            @Raymond in the Examples folder..., User Interface sub-folder

            1 Reply Last reply Reply Quote 0
            • Raymond
              Raymond last edited by

              Can you make a simple example please

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @Raymond last edited by cvp

                @Raymond from here touch the screen with multiple fingers and move them to see the effect

                # Variation of the 'Basic Scene' template that shows every
                # touch in a different (random) color that stays the same
                # for the duration of the touch.
                
                from scene import *
                from colorsys import hsv_to_rgb
                from random import random
                
                class TouchColors (Scene):
                	def setup(self):
                		self.touch_colors = {}
                	
                	def draw(self):
                		background(0, 0, 0)
                		for touch in self.touches.values():
                			r, g, b = self.touch_colors[touch.touch_id]
                			fill(r, g, b)
                			ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
                	
                	def touch_began(self, touch):
                		self.touch_colors[touch.touch_id] = hsv_to_rgb(random(), 1, 1)
                	
                	def touch_moved(self, touch):
                		pass
                
                	def touch_ended(self, touch):
                		del self.touch_colors[touch.touch_id]
                
                run(TouchColors())
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors