On Android How Do I Make Oddly Shaped Clipping Areas?
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  Now there's a cli
Solution 1:
From the Canvasjavadoc:
Canvas#clipPath(Path path, Region.Op op) - Modify the current clip with the specified path.
So, for your donut example:
- Create 2 Paths. One for the larger circle, one for the smaller circle.
- Canvas#clipPath( Path )with larger circle- Path.
- Call the - Canvas#clipPath( Path, Region.Op )method on your canvas with the smaller circle- Pathfor the first argument and the appropriate- Region.Openum value for the second argument.- PathlargePath=newPath(); largePath.addCircle(200,200,100,Direction.CW); PathsmallPath=newPath(); 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...
Post a Comment for "On Android How Do I Make Oddly Shaped Clipping Areas?"