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 rectangle with rounded corners on the screen. This method allows you to specify the rectangle's dimensions, color, corner radius, border width, and border color.

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. The vector components correspond to the top-left, top-right, bottom-right, and bottom-left corners, respectively.
  • borderWidth: A reference to a Vector4 structure that specifies the width of the border for each side of the rectangle. The vector components correspond to the left, top, right, and bottom borders, respectively.
  • borderColor: A reference to a Color structure that specifies the color of the rectangle's border.

Example

// Example of using DrawRoundedRectangle

// Define the rectangle
Rect rect = new Rect(10, 10, 100, 50);

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

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

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

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

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