How to draw smooth / rounded path?

前端 未结 2 1274
后悔当初
后悔当初 2020-12-24 12:51

I am creating Paths and adding multi lines in each path by using path.moveTo(x, y) and path.lineTo(x, y). Then canvas.drawPath(path, paint)

相关标签:
2条回答
  • 2020-12-24 13:09

    You probably don't want to lineTo(c, d) and then immediately moveTo(c, d) which is the same point. If you do this, you won't get a nice corner join on the two line segments, which may look like an ugly gap.

    Try removing that moveTo.

    0 讨论(0)
  • 2020-12-24 13:10

    Maybe this will create what you want

    paint.setColor(color);                    // set the color
    paint.setStrokeWidth(size);               // set the size
    paint.setDither(true);                    // set the dither to true
    paint.setStyle(Paint.Style.STROKE);       // set to STOKE
    paint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
    paint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
    paint.setPathEffect(new CornerPathEffect(10) );   // set the path effect when they join.
    paint.setAntiAlias(true);                         // set anti alias so it smooths
    

    :)

    0 讨论(0)
提交回复
热议问题