In Direct2D, rounded rectangle geometry can be created this way:
D2D1_ROUNDED_RECT rq = {0};
rq.rect.left = 0;
rq.rect.top = 0;
rq.rect.right = 100;
rq.rect.bottom = 100;
rq.radiusX = 5;
rq.radiusY = 5;
factory->CreateRoundedRectangleGeometry(rq, &geometry);
Where radiusX
and radiusY
are confusing me, because I can't understand how two values can independently describe 4 (4 rectangle corners radiuses).
Can I set each corner's radius separately like that, or do I need to do it manually using CreatePathGeometry()
instead?
According to the documentation, radiusX
and radiusY
are the radii for the quarter ellipse that are drawn in every corner.
You are not specifying the radius for every corner but for all of them at once. When radiusX
is larger than radiusY
, it's essentially a rounded rectangle that looks "squished".
If the radii are larger or equal to the half size of the rectangle, it'll be drawn like a regular ellipse that you would draw with D2D1_ELLIPSE
.