Graphics::drawRect: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
m (Replaced HTML with template)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Draws a rectangle on the screen.<br><br>-x: The relative X point of the center of the rectangle. (0.0-1.0, 0.0 is the left edge of the screen, 1.0 is the right edge of the screen)<br><br>-y: The relative Y point of the center of the rectangle. (0.0-1.0, 0.0 is the top edge of the screen, 1.0 is the bottom edge of the screen)<br><br>-width: The relative width of the rectangle. (0.0-1.0, 1.0 means the whole screen width)<br><br>-height: The relative height of the rectangle. (0.0-1.0, 1.0 means the whole screen height)<br><br>-R: Red part of the color. (0-255)<br><br>-G: Green part of the color. (0-255)<br><br>-B: Blue part of the color. (0-255)<br><br>-A: Alpha part of the color. (0-255, 0 means totally transparent, 255 means totall opaque)<br><br>The total number of rectangles to be drawn in one frame is apparently limited to 399.<br>
Draws a rectangle on the screen.
<br>*The total number of rectangles to be drawn in one frame is apparently limited to 399.
<br>
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">graphics.drawRect(x, y, width, height, r, g, b, a);</syntaxhighlight>
<pre>
mp.game.graphics.drawRect(pos_x, pos_y, width, height, color_r, color_g, color_b, color_a);
</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''x:''' float
*'''pos_x:''' float (0.0-1.0, 0.0 is the left edge of the screen, 1.0 is the right edge of the screen)
*'''y:''' float
*'''pos_y:''' float (0.0-1.0, 0.0 is the top edge of the screen, 1.0 is the bottom edge of the screen)
*'''width:''' float
*'''width:''' float (0.0-1.0, 1.0 means the whole screen width)
*'''height:''' float
*'''height:''' float (0.0-1.0, 1.0 means the whole screen height)
*'''r:''' int
*'''color_r:''' int
*'''g:''' int
*'''color_g:''' int
*'''b:''' int
*'''color_b:''' int
*'''a:''' int
*'''color_a:''' int (0-255, 0 means totally transparent, 255 means totally opaque)
 
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
{{ClientsideCode|
todo
<pre>
</syntaxhighlight>
mp.events.add('render', () => {
    if (condition) {
        mp.game.graphics.drawRect(0.35, 0.4, 0.3, 0.2, 215, 55, 55, 155);
    }
});
</pre>
}}
 
==See also==
==See also==
{{Graphics_function_c}}
{{Graphics_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 13:00, 26 October 2018

Draws a rectangle on the screen.
*The total number of rectangles to be drawn in one frame is apparently limited to 399.

Syntax

mp.game.graphics.drawRect(pos_x, pos_y, width, height, color_r, color_g, color_b, color_a);

Required Arguments

  • pos_x: float (0.0-1.0, 0.0 is the left edge of the screen, 1.0 is the right edge of the screen)
  • pos_y: float (0.0-1.0, 0.0 is the top edge of the screen, 1.0 is the bottom edge of the screen)
  • width: float (0.0-1.0, 1.0 means the whole screen width)
  • height: float (0.0-1.0, 1.0 means the whole screen height)
  • color_r: int
  • color_g: int
  • color_b: int
  • color_a: int (0-255, 0 means totally transparent, 255 means totally opaque)

Return value

  • Undefined

Example

Client-Side
mp.events.add('render', () => {
    if (condition) {
        mp.game.graphics.drawRect(0.35, 0.4, 0.3, 0.2, 215, 55, 55, 155);
    }
});

See also