我想创建更平滑的曲线,而不仅仅是线条角度。这是我现在画的图:
这是我的代码:
case FREEHAND:
float[] pts;
float[] ptk;
ptk = new float[2];
imageMatrix.invert(inv);
if (mCurrentShape == null) {
mCurrentShape = new Line();
pts = new float[2];
((Line) mCurrentShape).setBegin(mDownPoint);
pts[0] = (float)((Line) mCurrentShape).getBegin().getX();
pts[1] = (float)((Line) mCurrentShape).getBegin().getY();
inv.mapPoints(pts);
((Line) mCurrentShape).getPath().moveTo(pts[0], pts[1]);
}
ptk[0] = (float)currentPoint.getX();
ptk[1] = (float)currentPoint.getY();
inv.mapPoints(ptk);
((Line) mCurrentShape).getPath().lineTo(ptk[0], ptk[1]);
break;
手绘代码:
package aa.bb.cc;
import java.util.ArrayList;
import android.graphics.Path;
public class FreeHand extends Shape{
private ArrayList<Path>_graphics;
public FreeHand(){
super();
_graphics = new ArrayList<Path>();
}
public ArrayList<Path> getGraphicsPath(){
return _graphics;
}
}