Graphics::drawRect: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Replaced HTML with template)
 
Line 2: Line 2:
<br>*The total number of rectangles to be drawn in one frame is apparently limited to 399.
<br>*The total number of rectangles to be drawn in one frame is apparently limited to 399.
<br>
<br>
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawRect(pos_x, pos_y, width, height, color_r, color_g, color_b, color_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 ===
*'''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_x:''' float (0.0-1.0, 0.0 is the left edge of the screen, 1.0 is the right edge of the screen)
Line 13: Line 17:
*'''color_b:''' int
*'''color_b:''' int
*'''color_a:''' int (0-255, 0 means totally transparent, 255 means totally opaque)
*'''color_a:''' int (0-255, 0 means totally transparent, 255 means totally opaque)
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<pre>
<syntaxhighlight lang="javascript">
 
mp.events.add('render', () => {
mp.events.add('render', () => {
     if (condition) {
     if (condition) {
         mp.game.graphics.drawRect(0.35, 0.4, 0.3, 0.2, 215, 55, 55, 155);
         mp.game.graphics.drawRect(0.35, 0.4, 0.3, 0.2, 215, 55, 55, 155);
     }
     }
});
});
</syntaxhighlight>
</pre>
</div>
}}
 
==See also==
==See also==
{{Graphics_s_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