如何在Kivy中记录多点触控手势

如何在Kivy中记录多点触控手势

本文介绍了如何在Kivy中记录多点触控手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经基于提供的Kivy使用了手势代码示例以记录和识别单点触摸手势.但是,我不确定如何扩展此代码以识别多点触摸手势.比方说,捏.

I have used the gestures code based on the provided Kivy examples to record and recognize single touch gestures. However, I am not sure how to extend this code to recognize multi-touch gestures. Let's say, for example, a pinch.

我的问题变得特别复杂,因为我使用的笔记本电脑具有零多点触控功能.如何结合两个单一手势?有没有可用的示例?

My problem becomes specially complicated because I use a laptop with zero multi-touch functionality. How do I combine two single gestures? Is there any example available?

推荐答案

从1.9.0版开始,Kivy集成了多点触摸手势识别器:请查看 kivy.multistroke .我个人还没有时间进行测试.

From 1.9.0, Kivy got a multi-touch gesture recognizer integrated: have a look at kivy.multistroke. I personally didn't got time to test it yet.

如果您要根据手势进行映射或操作,请散射.捏合可通过2到N触摸完成,并集成了旋转和平移功能.您可以将转换限制为仅缩放而不是旋转/平移.并且,当所有触摸释放后,您可以将比例动画设置为最接近的所需值.您还可以设置最小比例和最大比例的限制.

If you want to map or act depending of the gesture, you might be interested by the Scatter. Pinch can be done with 2 to N touch, with rotation and translation integrated. You can restrict the transformation to just scale and not rotation / translation. And, when all the touches are released, you could animate the scale to the closest wanted value. You can also set a limit for the minimum scale and maximum scale.

只需很少的参数和代码,您就可以捏住缩放,de/un捏住以缩放等.也许就是您想要的:)(例如捏住以放大图像或将图像放到全屏状态).

With few parameters and code, you can pinch to zoom, de/un pinch to unzoom, etc. Maybe that's what you want :) (like pinch to zoom in a image, or put an image in fullscreen).

您还可以只使用Scatter的scale参数或Scale矩阵来做自己的事情:)

You can also just use the Scatter's scale parameters, or Scale's matrix to do your own things :)

这篇关于如何在Kivy中记录多点触控手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:47