我正在使用手指画线,到目前为止,我已经想出了以下代码:
case MotionEvent.ACTION_MOVE:
//return if touch is in this area of canvas
if (x<=430 || y<=80 || y>=490) return true;
//draw path using x and y co-ordinates
mPath.quadTo(previousPoint.x, previousPoint.y, (x+previousPoint.x)/2,(y+previousPoint.y)/2);
canvas.drawPath(mPath, paint);
previousPoint.x = x;
previousPoint.y = y;
//invalidate canvas on move
imageView.invalidate();
break;
case MotionEvent.ACTION_UP:
Xend=x;
Yend=y;
//validate that is it true?
if((Xstart>=780 && Xstart<=830) && (Xend>=780 && Xend<=830) && (Ystart>=10 && Ystart<=200) && Yend<=800 && Yend>=300){
//show toast if correct
Toast.makeText(getBaseContext(), "Correct", Toast.LENGTH_SHORT).show();
}else{
//show toast with XY co-ordinates that your attempt is wrong
Toast.makeText(getBaseContext(), "Wrong attempt\n Xstart: "+Xstart+"\n Xend:"+Xend+"\n Ystart: "+Ystart+"\nYend:"+Yend, Toast.LENGTH_SHORT).show();
}
imageView.invalidate();
break;
但不幸的是,上面的代码不能满足我的要求。我想创建按字母顺序组织的工作表,用户通过触摸进行操作。我想知道他从哪里开始,他要去哪里,他在哪里结束以识别他在画布上绘制的内容,我知道从哪里获取接触点,但问题是如何识别画布上绘制的内容?想在 Playstore 上识别像这样的 VisionObjects应用程序。