florent37 / ShapeOfView

Give a custom shape to any android view, Material Design 2 ready
Apache License 2.0
3.12k stars 400 forks source link

radius on PolygonView #55

Open croccio opened 5 years ago

croccio commented 5 years ago

is it possible to have a corner radius on PolygonView?

croccio commented 5 years ago

@florent37 maybe this can help u

Find below a simple example to draw rounded corner polygons (i.e. triangle, rectangle, etc.)

    Paint paint = new Paint();
    paint.setColor(Color.GREEN);
    paint.setStrokeWidth(6);
    float radius = 50.0f;
    CornerPathEffect corEffect = new CornerPathEffect(radius);
    paint.setPathEffect(corEffect);
    Path path = new Path();
    path.moveTo(20, 20);
    path.lineTo(400, 20);
    path.lineTo(600, 300);
    path.lineTo(400, 400);
    path.lineTo(20, 400);
    path.close();
    canvas.drawPath(path, paint);