Remove pixel on stroke painted from clipped path Android

Viewed 72

I'm using a simple custom view which draw a path and clip its children.

Code used :

private void config() {
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setShadowLayer(10.0f, 4.0f, 4.0f, DARK)
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.WHITE);
        paint.setStrokeWidth(20);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        canvas.save();

        circlePath.reset();
        circlePath.addCircle(cx, cy, circleRadius, Path.Direction.CW);

        canvas.drawPath(circlePath, paint);
        canvas.clipPath(circlePath);

        super.dispatchDraw(canvas);
        canvas.restore();
    }

The path is fully transparent with only a white stroke. If there is no child inside this view container everything is fine.

Empty path :

enter image description here

Problem : I have noticed when a child is clipped, it seems that pixels appears around the white stroke, and only inside the path

Path with a black clipped children inside:

enter image description here

I zoomed and resized screenshots to better understand but also in real size pixels are visible.
I tried without shadowLayer but there is still pixels

Could someone tell me what is the problem source and how to fix it ?

0 Answers
Related