如何在Kivy中记录多点触控手势? [英] How to record multitouch gestures in Kivy?

查看:99
本文介绍了如何在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集成了多点触摸手势识别器:请查看

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.

如果您要根据手势进行映射或操作,请

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中记录多点触控手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆