Squeezing or expanding 2 fingers on this UI with given motion range and duration. Args: direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding percent (:py:obj:`float`): squeezing range from or expanding ra
(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1)
| 518 | return self.focus(focus1).drag_to(self.focus(focus2), duration=duration) |
| 519 | |
| 520 | def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1): |
| 521 | """ |
| 522 | Squeezing or expanding 2 fingers on this UI with given motion range and duration. |
| 523 | |
| 524 | Args: |
| 525 | direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding |
| 526 | percent (:py:obj:`float`): squeezing range from or expanding range to of the bounds of the UI |
| 527 | duration (:py:obj:`float`): time interval in which the action is performed |
| 528 | dead_zone (:py:obj:`float`): pinching inner circle radius. should not be greater than ``percent`` |
| 529 | |
| 530 | Raises: |
| 531 | PocoNoSuchNodeException: raised when the UI element does not exist |
| 532 | """ |
| 533 | |
| 534 | if direction not in ('in', 'out'): |
| 535 | raise ValueError('Argument `direction` should be one of "in" or "out". Got {}'.format(repr(direction))) |
| 536 | if dead_zone >= percent: |
| 537 | raise ValueError('Argument `dead_zone` should not be greater than `percent`. dead_zoon={}, percent={}' |
| 538 | .format(repr(dead_zone), repr(percent))) |
| 539 | |
| 540 | w, h = self.get_size() |
| 541 | x, y = self.get_position() |
| 542 | # focus = self._focus or [0.5, 0.5] |
| 543 | tracks = make_pinching(direction, [x, y], [w, h], percent, dead_zone, duration) |
| 544 | speed = math.sqrt(w * h) * (percent - dead_zone) / 2 / duration |
| 545 | |
| 546 | # 速度慢的时候,精度适当要提高,这样有助于控制准确 |
| 547 | ret = self.poco.apply_motion_tracks(tracks, accuracy=speed * 0.03) |
| 548 | return ret |
| 549 | |
| 550 | def pan(self, direction, duration=2.0): |
| 551 | raise NotImplementedError |
nothing calls this directly
no test coverage detected