When you draw a path with a bigger line stroke width, you might notice uggly edges.
![android canvas no round stroke corners](https://i2.wp.com/blog.kibotu.net/images/doodle_drawer_no_round_corners.png?w=195)
In order to get them round you simply need to change the stroke join to round. Here are some default settings I’m using in my Doodle Drawer app.
1 2 3 4 5 6 7 8 9 10 | private void initPaint() { paint = new Paint(); paint.setAntiAlias(true); // enable anti aliasing paint.setColor(Color.WHITE); // set default color to white paint.setDither(true); // enable dithering 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(getStrokeWidth())); // set the path effect when they join. } |
At the end it should look like this:
![round corners](https://i1.wp.com/blog.kibotu.net/images/doodle_drawer_round_corners.png?w=195)
Leave a Reply