其他分享
首页 > 其他分享> > Android 项目总结(自定义view之贝塞尔曲线与path路径)

Android 项目总结(自定义view之贝塞尔曲线与path路径)

作者:互联网

 

public class PathView extends View {

    private Path mPath = new Path();
    private Paint mPaint = new Paint();

    public PathView(Context context) {
        super(context);
        mPaint.setColor(Color.RED);

        mPaint.setStrokeWidth(4);
        mPaint.setStyle(Paint.Style.STROKE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//
        mPaint.setStyle(Paint.Style.FILL);
        //一阶贝塞尔曲线,表示的是一条直线
        mPath.moveTo(100, 70); //移动
//        mPath.lineTo(140, 800);//连线
        //等同于上一行代码效果
        mPath.rLineTo(40, 730);
//        mPath.lineTo(250, 600);
        mPath.close();//设置曲线是否闭合

//        //添加子图形addXXX
//      

标签:Style,lineTo,mPath,自定义,mPaint,PathView,Paint,path,Android
来源: https://blog.csdn.net/qq_27248989/article/details/122764893