I have a Path
that crosses over itself and I want to change the color of the areas that are gone over more than once. Like below:
So I set up 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 below image. There are two Paths in this picture with their endpoints labeled.
I'm drawing each path onto a Canvas
.
Separate Path
s correctly darken their shared area, but a single Path
does not. How can I achieve an effect similar to the first image?
View.onDraw()
draw your bitmap onto the view. – Insolence