natives.drawRect

From GTA Connected
Jump to navigation Jump to search

Function Client Only icon-iv.png Online and Offline

Available since Client 1.0.0

void natives.drawRect(Vec2 position, Vec2 size, int r, int g, int b, int a)

The natives.drawRect function is used to Draws a rectangle on the screen with the specified position, size, and color.

Parameters

1) Vec2 position Normalized screen coordinates (0.0–1.0) for the rectangle’s center.
2) Vec2 size Rectangle size relative to screen (width, height).
3) int r Red color value (0–255).
4) int g Green color value (0–255).
5) int b Blue color value (0–255).
6) int a Alpha transparency value (0–255).

Return

void This function doesn't return a value.

Notes

  • This function must be called inside a rendering event such as OnDrawnHUD so the rectangle is drawn each frame.

Examples

Example 1 - JavaScript:

addEventHandler("OnDrawnHUD", function() {

   // Draw a semi-transparent red rectangle in the center of the screen
   natives.drawRect(new Vec2(0.5, 0.5), new Vec2(0.3, 0.2), 255, 0, 0, 150);

});

Compatibility

There isn't any compatibility information for this function.