natives.drawRect: Difference between revisions
Jump to navigation
Jump to search
ChrisGame20 (talk | contribs) (Created page with "{{ScriptItem |endpoint = client |games = iv |type = function |name = natives.drawRect |parameters = Vec2 position, Vec2 size, int r, int g, int b, int a |parameter1 = Vec2 position Normalized screen coordinates (0.0–1.0) for the rectangle’s center |parameter2 = Vec2 size Rectangle size relative to screen (width, height) |parameter3 = int r Red color value (0–255) |parameter4 = int g Green color value (0–255) |parameter5 = int b Blue color value (0–255) |paramet...") |
(No difference)
|
Latest revision as of 07:47, 24 November 2025
Function Client Only ![]()
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.