I have a Path that intersects itself, and I want to change the color of the areas that have passed more than once. As below:

So, I set my paint.
highlighterPaint = new Paint(); highlighterPaint.setAntiAlias(true); strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, displayMetrics); highlighterPaint.setStrokeWidth(strokeWidth); highlighterPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DARKEN)); highlighterPaint.setAlpha(200); highlighterPaint.setStyle(Paint.Style.STROKE); highlighterPaint.setStrokeJoin(Paint.Join.ROUND);
But when I call canvas.drawPath(mPath1, highlighterPaint) and canvas.drawPath(mPath2, highlighterPaint) , I get the following image. There are two contours in this image with their end points.

I draw every way on Canvas .
To divide Path correctly darkens the general area, but one Path does not. How can I achieve an effect similar to the first image?
source share