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

book_4_sparkGenerated
code_blocksInput

Description

The DrawRect method in the HudPainter class is used to draw a rectangle on the HUD (Heads-Up Display) with specified properties such as color, corner radius, border width, and border color. This method is part of the rendering process in the Sandbox game engine, allowing developers to customize the appearance of UI elements.

Usage

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

  • rect: A reference to a 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 the corners 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 HudPainter instance is properly initialized and that the rendering context is set up before calling this method.

Example

// Example usage of HudPainter.DrawRect

// Create a HudPainter instance
HudPainter hudPainter = new HudPainter();

// Define the rectangle properties
Rect rect = new Rect(10, 10, 100, 50);
Color fillColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); // Gray color
Vector4 cornerRadius = new Vector4(5, 5, 5, 5); // Rounded corners
Vector4 borderWidth = new Vector4(2, 2, 2, 2); // Border width
Color borderColor = new Color(1.0f, 0.0f, 0.0f, 1.0f); // Red border

// Draw the rectangle
hudPainter.DrawRect(ref rect, ref fillColor, ref cornerRadius, ref borderWidth, ref borderColor);