As background, I am new to Android graphics. I'm trying to create a rectangle with rounded corners using Path specifically (I don't want to use method addRoundRect
as I will make changes to my Path
object later to not be rectangular). I want this to have the same curvature as a shape with corners with a radius of 12 dp. I'd like to use the methods rQuadTo or quadTo (based off of this question), but am a bit confused how to get the corners to match each other perfectly. Can someone explain the math behind how to to achieve this and what setting the radius exactly mean for drawable resource shape (is this a correct definition?)? Visuals would be help as well! Thanks.
Asked
Active
Viewed 697 times
1
1 Answers
0
Yes, link contains correct definition.
To build rounded corner with quadratic Bezier quadTo
, you should start curve (end straight line) at distance r=12
before corner position, make control point exactly at corner position (to provide symmetry) and make end point at distance r
after corner at perpendicular edge. Quadratic Bezier curve does not give perfect circle arc, but it is not significant for small sizes.
Example:
Horizontal edge in right direction to corner 100, 100
.
End point of line is 88, 100
. (and starting point of curve)
And quadto(100, 100, 100, 112)

MBo
- 77,366
- 5
- 53
- 86