} else {//范围内触摸
smallCircleX = (int) event.getX();
smallCircleY = (int) event.getY();
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
smallCircleX = bigCircleX;
smallCircleY = bigCircleY;
}
return true;
}
弧度计算
通过 event.getX(), event.getY()获得当前的触摸点,与圆点进行计算,获取弧度
/***
- 得到两点之间的弧度
*/
public float getRad(float px1, float py1, float px2, float py2) {
float x = px2 - px1;
float y = py1 - py2;
//斜边的长
float z = (float) Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
float cosAngle = x / z;
float rad = (float) Math.acos(cosAngle);
if (py2 < py1) {
rad = -rad;
}
return rad;
}
图形绘制
通过 canvas.drawCircle()和 canvas.drawBitmap()分别进行遥感按钮和遥感背景的绘制,注意对遥感背景的保存,如果在绘