@@ -415,24 +415,29 @@ def transform_with_touch(self, touch):
415
415
if len (self ._touches ) == 1 :
416
416
return changed
417
417
418
- # we have more than one touch...
419
- points = [Vector (self ._last_touch_pos [t ]) for t in self ._touches ]
418
+ # we have more than one touch... list of last known pos
419
+ points = [Vector (self ._last_touch_pos [t ]) for t in self ._touches
420
+ if t is not touch ]
421
+ # add current touch last
422
+ points .append (Vector (touch .pos ))
420
423
421
424
# we only want to transform if the touch is part of the two touches
422
- # furthest apart! So first we find anchor, the point to transform
423
- # around as the touch farthest away from touch
424
- anchor = max (points , key = lambda p : p .distance (touch .pos ))
425
+ # farthest apart! So first we find anchor, the point to transform
426
+ # around as another touch farthest away from current touch's pos
427
+ anchor = max (points [: - 1 ] , key = lambda p : p .distance (touch .pos ))
425
428
426
429
# now we find the touch farthest away from anchor, if its not the
427
430
# same as touch. Touch is not one of the two touches used to transform
428
431
farthest = max (points , key = anchor .distance )
429
- if points . index ( farthest ) != self . _touches . index ( touch ) :
432
+ if farthest is not points [ - 1 ] :
430
433
return changed
431
434
432
435
# ok, so we have touch, and anchor, so we can actually compute the
433
436
# transformation
434
437
old_line = Vector (* touch .ppos ) - anchor
435
438
new_line = Vector (* touch .pos ) - anchor
439
+ if not old_line .length (): # div by zero
440
+ return changed
436
441
437
442
angle = radians (new_line .angle (old_line )) * self .do_rotation
438
443
self .apply_transform (Matrix ().rotate (angle , 0 , 0 , 1 ), anchor = anchor )
0 commit comments