我的代码基本上来自这个例子(http://corner.squareup.com/2010/07/smooth-signatures.html)和Google API(FingerPaint),但现在我想使用该类VelocityTracker来改变笔画宽度,具体取决于在我的手指速度.
我以为我可以将路径分成更小的部分,但我没有找到任何例子.还有第二篇文章(http://corner.squareup.com/2012/07/smoother-signatures.html),但我没有特定的bezier曲线类,也没有收集所有的点,ArrayList所以他们的例子用于调整笔划宽度不是很有帮助.
有谁知道如何处理这个?两周前我开始学习代码,所以我对这些东西都很新.
编辑:我试图实现我的MotionEvents的速度,我使用LogCat来跟踪运行应用程序时的当前速度.它确实有效,但当我尝试使用速度作为mPaint.setStrokeWidth参数的一部分时,我没有得到我真正想要的东西.我从画布上绘制的路径的宽度从我开始绘制线条的那一刻起一直在变化,直到我将手指向上移动.这就是为什么我想将路径分成更小的部分,因为现在只有最后一个跟踪的速度会影响strokeWidth.
public class SignatureView extends View {
private static final String TAG = SignatureView.class.getSimpleName();
private static final float STROKE_WIDTH = 10;
private static final float HALF_STROKE_WIDTH = STROKE_WIDTH / 2;
private final double TOUCH_TOLERANCE = 5;
private int h = getResources().getDisplayMetrics().heightPixels;
private int w = getResources().getDisplayMetrics().widthPixels;
private Path mPath = new Path();
private Paint mPaint = new Paint();
private Paint mBitmapPaint = new Paint(Paint.DITHER_FLAG);
private Bitmap mBitmap = …Run Code Online (Sandbox Code Playgroud)