我创建了一个示例绘图应用程序,用户可以在其中使用宽度可变的笔画进行绘制。到目前为止,具有可变笔划的绘制路径都可以使用,但是绘制的线条并不平滑。我用来实现的代码如下所示。
过去两天来,我一直无法解决这个问题,请帮我解决。
使用可变笔触宽度绘制路径的代码
public class FingerPaint extends GraphicsActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
}
public void colorChanged(int color) {
}
public class MyView extends View {
private static final float STROKE_WIDTH = 5f;
private Paint paint = new Paint();
private Path mPath = new Path();
ArrayList<Path> mPaths = new ArrayList<Path>();
ArrayList<Integer> mStrokes = new ArrayList<Integer>();
private float lastTouchX;
private float lastTouchY;
private final RectF dirtyRect = new RectF();
private int lastStroke = -1;
int variableWidthDelta …Run Code Online (Sandbox Code Playgroud)