Here is how to create a clipping area the shape of a circle:
Path path = new Path();
path.addCircle(200,200,100,Direction.CW);
c.clipPath(path); // c is a Canvas
From the Canvas
javadoc:
Canvas#clipPath(Path path, Region.Op op)
- Modify the current clip with the specified path.
So, for your donut example:
Canvas#clipPath( Path )
with larger circle Path
.Call the Canvas#clipPath( Path, Region.Op )
method on your canvas with the smaller circle Path
for the first argument and the appropriate Region.Op enum value for the second argument.
Path largePath = new Path();
largePath.addCircle(200,200,100,Direction.CW);
Path smallPath = new Path();
smallPath.addCircle(200,200,40,Direction.CW);
c.clipPath(largePath); // c is a Canvas
c.clipPath(smallPath, Region.Op.DIFFERENCE);
Again, modify the Region.Op
enum value to get different effects...