There is a problem with anti-alias when trying to draw several times in one place using android Canvas .
First, I initialize paint = new Paint(Paint.ANTI_ALIAS_FLAG) , and then set the maximum stroke length in Paint.Cap.ROUND .
Then, if I call canvas.drawPoint(x, y, paint) , it calls the following result once:

When calling canvas.drawPoint(x, y, paint) several times (100 in this example), it calls the following:

I created an example with minimal code to run this on GitHub: android-canvas-antialias
I noticed that if I draw points with a certain distance, the anti-alias works as expected (first image). But when drawing with a slight offset, the same problem arises with an alias (second image).
Is there any setting that needs to be made for this to work when drawing dots in one place? Or I just can’t paint in one place (or with a very slight offset)?
EDIT: The real problem is that I am trying to draw a line segment of variable width. See MainActivity.drawSegment in the git repository.
source share