public static void FillRoundedRect(float x, float y, float z, float width, float height, float radius, Color4 color)
{
if (radius <= 0)
{
FillRect(x, y, z, width, height, color);
return;
}
Texture.BindNone();
SetColor(color);
if (radius > width / 2)
{
radius = width / 2;
}
if (radius > height / 2)
{
radius = height / 2;
}
FillCorner(x, y, z, radius, 0);
FillCorner(x + width - radius, y, z, radius, MathHelper.DegreesToRadians(90));
FillCorner(x, y + height - radius, z, radius, MathHelper.DegreesToRadians(-90));
FillCorner(x + width - radius, y + height - radius, z, radius, (float)Math.PI);
bool xRect = radius < width / 2;
bool yRect = radius < height / 2;
if (xRect)
{
FillRect(x + radius, y, z, width - (radius * 2), radius, color);
FillRect(x + radius, y + height - radius, z, width - (radius * 2), radius, color);
}
if (yRect)
{
FillRect(x, y + radius, z, radius, height - (radius * 2), color);
FillRect(x + width - radius, y + radius, z, radius, height - (radius * 2), color);
}
if (xRect && yRect)
FillRect(x + radius, y + radius, z, width - (radius * 2), height - (radius * 2), color);
}