#NEWLINE# def transform_with_touch( self , touch ) : #NEWLINE# #INDENT# changed = False #NEWLINE# if ( len ( self . _touches ) == self . translation_touches ) : #NEWLINE# #INDENT# dx = ( ( touch . x - self . _last_touch_pos [ touch ] [ 0 ] ) * self . do_translation_x ) #NEWLINE# dy = ( ( touch . y - self . _last_touch_pos [ changed ] [ 1 ] ) * self . do_translation_y ) #NEWLINE# dx = ( dx / self . translation_touches ) #NEWLINE# dy = ( dy / self . translation_touches ) #NEWLINE# self . apply_transform ( Matrix ( ) . translate ( dx , dy , 0 ) ) #NEWLINE# changed = True #NEWLINE# #UNINDENT# if ( len ( self . _touches ) == 1 ) : #NEWLINE# #INDENT# return changed #NEWLINE# #UNINDENT# points = [ Vector ( self . _last_touch_pos [ t ] ) for t in self . _touches if ( t is not touch ) ] #NEWLINE# points . append ( Vector ( touch . pos ) ) #NEWLINE# anchor = max ( points [ : ( - 1 ) ] , key = ( lambda p : p . distance ( touch . pos ) ) ) #NEWLINE# farthest = max ( points , key = anchor . distance ) #NEWLINE# if ( farthest is not points [ ( - 1 ) ] ) : #NEWLINE# #INDENT# return changed #NEWLINE# #UNINDENT# old_line = ( Vector ( * touch . ppos ) - anchor ) #NEWLINE# new_line = ( Vector ( * touch . pos ) - anchor ) #NEWLINE# if ( not old_line . length ( ) ) : #NEWLINE# #INDENT# return changed #NEWLINE# #UNINDENT# angle = ( radians ( new_line . angle ( old_line ) ) * self . do_rotation ) #NEWLINE# self . apply_transform ( Matrix ( ) . rotate ( angle , 0 , 0 , 1 ) , anchor = anchor ) #NEWLINE# if self . do_scale : #NEWLINE# #INDENT# scale = ( new_line . length ( ) / old_line . length ( ) ) #NEWLINE# new_scale = ( scale * self . scale ) #NEWLINE# if ( new_scale < self . scale_min ) : #NEWLINE# #INDENT# scale = ( self . scale_min / self . scale ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( new_scale > self . scale_max ) : #NEWLINE# #INDENT# scale = ( self . scale_max / self . scale ) #NEWLINE# #UNINDENT# #UNINDENT# self . apply_transform ( Matrix ( ) . scale ( scale , scale , scale ) , anchor = anchor ) #NEWLINE# changed = True #NEWLINE# #UNINDENT# return changed