点操作
moveTo(float x, float y) //改变接下来操作的起点位置为(x,y)
rMoveTo(float dx, float dy) //接下来要操作的起点位置为(x+dx,y+dy)
setLastPoint(float dx, float dy) //改变前一步操作点的位置,会改变前一步的操作
先来看moveTo和rMoveTo的区别,示例:
//初始化Paint
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10f);
//初始化Path
Path path = new Path();
//将坐标系原点从(0,0)移动到(100,100)
path.moveTo(100, 100);
//画从(100,100)到(400,400)之间的直线
path.lineTo(400, 400);
//path.rMoveTo(0, 100); //暂时注释
path.lineTo(400, 800);
canvas.drawPath(path, mPaint);
效果图:
|