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 Canvas
javadoc:
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 circlePath
.Call the
Canvas#clipPath( Path, Region.Op )
method on your canvas with the smaller circlePath
for the first argument and the appropriateRegion.Op
enum 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?"