gpt4 book ai didi

java - 使用 Processing 检测 android 上的捏合 Action

转载 作者:搜寻专家 更新时间:2023-11-01 09:20:26 26 4
gpt4 key购买 nike

我正在开发一个用 Processing 3 编写的 android 应用程序。它需要能够在启动捏合 Action “放大”时增加一个变量,并在“缩小”时减少。

在 Processing 中是否有执行此操作的内置方法,如果没有,有人可以在正确的方向上给我提示以创建我自己的解决方案吗?

提前致谢。

最佳答案

看看 Ketai Library - KetaiGesture :

Provides gesture recognition services to a processing sketch. Toreceive gesture events a sketch can define the following methods:

...

onPinch(float x, float y, float r) - x,y of center, r is the distance

使用捏合 Action 更改圆圈大小的代码示例:

import ketai.ui.*;
import android.view.MotionEvent;

float ellipseWidth = 50;
float ellipseHeight = 50;
KetaiGesture gesture;

void setup() {
size(displayWidth, displayHeight);
gesture = new KetaiGesture(this);
}

void draw() {
orientation(PORTRAIT);
background(0);
fill(0);
stroke(255);
ellipse(width/2, height/2, ellipseWidth, ellipseHeight);
}

void onPinch (float x, float y, float d) {
ellipseWidth += d;
ellipseHeight += d;
}

public boolean surfaceTouchEvent(MotionEvent event) {
//Call this to keep mouseX and mouseY updated
super.surfaceTouchEvent(event);

//Forward the event to the class for processing
return gesture.surfaceTouchEvent(event);
}

希望这对您有所帮助!

enter image description here

关于java - 使用 Processing 检测 android 上的捏合 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56306643/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com