Reputation: 12326
In android canvas, I've defined a clipping area with many shapes (a rectangle and 2 circles). I want to get the inscribed rectangle defined by the clipping area.
Canvas has a method called getClipBounds()
which gives me the circumscribed rectangle, how do I get the inscribed rectangle instead?
Edit: Here's some info on how the original shape is made:
Region.Op.INTERSECT
Region.Op.INTERSECT
Region.Op.DIFFERENCE
Upvotes: 4
Views: 502
Reputation: 4641
This can be determined mathematically if you know the radius & center of both circles.
Find two the intersection points of circles with the getClipBounds() rectangle. -The the second highest intersection point between the red circle and the getClipBounds() rectangle holds the upper y coordinate of the rectangle. -The high intersection point between the white circle and the getClipBounds() rectangle holds the lower y coordinate of the rectangle. -The x bounds are already given by the getClipBounds() rectangle.
You can construct your three shapes from there.
Upvotes: 1