Graphics::drawRect: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
No edit summary
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><br>
*The total number of rectangles to be drawn in one frame is apparently limited to 399.
<br>
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawRect(x, y, width, height, r, g, b, a);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.graphics.drawRect(pos_x, pos_y, width, height, color_r, color_g, color_b, color_a);</syntaxhighlight>
=== 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==
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
 
mp.events.add('render', () => {
 
    if (condition) {
 
        mp.game.graphics.drawRect(0.35, 0.4, 0.3, 0.2, 215, 55, 55, 155);
 
    }
});
</syntaxhighlight>
</syntaxhighlight>
</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]]

Revision as of 18:54, 5 October 2017

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