OpenTkEngine.Core.Graphics.DrawRoundedRect C# (CSharp) Method

DrawRoundedRect() public static method

public static DrawRoundedRect ( float x, float y, float z, float width, float height, float radius, int lineWidth, Color4 color ) : void
x float
y float
z float
width float
height float
radius float
lineWidth int
color Color4
return void
        public static void DrawRoundedRect(float x, float y, float z, float width, float height, float radius, int lineWidth, Color4 color)
        {
            if (radius <= 0)
            {
                DrawRect(x, y, z, width, height, lineWidth, color);
                return;
            }
            Texture.BindNone();
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            GL.LineWidth(lineWidth);
            SetColor(color);
            if (radius > width / 2)
            {
                radius = width / 2;
            }
            if (radius > height / 2)
            {
                radius = height / 2;
            }

            DrawCorner(x, y, z, radius, 0);
            DrawCorner(x + width - radius, y, z, radius, MathHelper.DegreesToRadians(90));

            DrawCorner(x, y + height - radius, z, radius, MathHelper.DegreesToRadians(-90));
            DrawCorner(x + width - radius, y + height - radius, z, radius, (float)Math.PI);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            bool xRect = radius < width / 2;
            bool yRect = radius < height / 2;
            if (xRect)
            {
                FillRect(x + radius, y - (lineWidth * 0.5f), z, width - (radius * 2), lineWidth, color);
                FillRect(x + radius, y + height - (lineWidth * 0.5f), z, width - (radius * 2), lineWidth, color);
            }
            if (yRect)
            {
                FillRect(x - (lineWidth * 0.5f), y + radius, z, lineWidth, height - (radius * 2), color);
                FillRect(x + width - (lineWidth * 0.5f), y + radius, z, lineWidth, height - (radius * 2), color);
            }
        }