static void DrawRoundedRectangle( Sandbox.Rect& rect, Color& color, Vector4& cornerRadius, Vector4& borderWidth, Color& borderColor )

robot_2Generated
code_blocksInput

Description

The DrawRoundedRectangle method is a static method of the Sandbox.Graphics class. It is used to draw a rounded rectangle on the screen with specified dimensions, color, corner radius, border width, and border color. This method is useful for rendering UI elements or other graphical components that require rounded corners.

Usage

To use the DrawRoundedRectangle method, you need to provide the following parameters:

  • rect: A reference to a Sandbox.Rect structure that defines the position and size of the rectangle.
  • color: A reference to a Color structure that specifies the fill color of the rectangle.
  • cornerRadius: A reference to a Vector4 structure that defines the radius of each corner of the rectangle. Each component of the vector corresponds to a corner of the rectangle.
  • borderWidth: A reference to a Vector4 structure that specifies the width of the border for each side of the rectangle.
  • borderColor: A reference to a Color structure that defines the color of the border.

Ensure that the Sandbox.Graphics class is active and the rendering context is properly set up before calling this method.

Example

// Example of using DrawRoundedRectangle

// Define the rectangle position and size
Rect rect = new Rect(10, 10, 200, 100);

// Define the fill color
Color fillColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); // Gray color

// Define the corner radius for each corner
Vector4 cornerRadius = new Vector4(10, 10, 10, 10); // 10 units radius for all corners

// Define the border width for each side
Vector4 borderWidth = new Vector4(2, 2, 2, 2); // 2 units border width for all sides

// Define the border color
Color borderColor = new Color(0, 0, 0, 1.0f); // Black color

// Draw the rounded rectangle
Graphics.DrawRoundedRectangle(ref rect, ref fillColor, ref cornerRadius, ref borderWidth, ref borderColor);