Graphics::drawLine: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Draws a depth-tested line from one point to another.<br>----------------<br>x1, y1, z1 : Coordinates for the first point<br>x2, y2, z2 : Coordinates for the second point<br>r, g, b, alpha : Color with RGBA-Values<br>I recommend using a predefined function to call this.<br>[VB.NET]<br>Public Sub DrawLine(from As Vector3, [to] As Vector3, col As Color)<br>    [Function].Call(Hash.DRAW_LINE, from.X, from.Y, from.Z, [to].X, [to].Y, [to].Z, col.R, col.G, col.B, col.A)<br>End Sub<br><br>[C#]<br>public void DrawLine(Vector3 from, Vector3 to, Color col)<br>{<br>    Function.Call(Hash.DRAW_LINE, from.X, from.Y, from.Z, to.X, to.Y, to.Z, col.R, col.G, col.B, col.A);<br>}
{{ClientsideJsFunction}}
{{JSContainer|
 
Draws a line bewteen the 2 vectors, colors and alpha are between 0 and 255.
Must be called every frame.
 
===Required Params===
*'''x1:''' {{RageType|number}}
*'''y1:''' {{RageType|number}}
*'''z1:''' {{RageType|number}}
*'''x2:''' {{RageType|number}}
*'''y2:''' {{RageType|number}}
*'''z2:''' {{RageType|number}}
*'''red:''' {{RageType|number}}
*'''green:''' {{RageType|number}}
*'''blue:''' {{RageType|number}}
*'''alpha:''' {{RageType|number}}
 
===Return value===
*''' {{RageType|void}} '''
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawLine(x1, y1, z1, x2, y2, z2, r, g, b, alpha);</syntaxhighlight>
<syntaxhighlight lang="javascript">
=== Required Arguments ===
mp.game.graphics.drawLine(x1, y1, z1, x2, y2, z2, red, green, blue, alpha)
*'''x1:''' float
</syntaxhighlight>
*'''y1:''' float
 
*'''z1:''' float
*'''x2:''' float
*'''y2:''' float
*'''z2:''' float
*'''r:''' int
*'''g:''' int
*'''b:''' int
*'''alpha:''' int
===Return value===
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
//draw a line from player's position to their forward looking position
mp.events.add('render', () => {
    const {x, y, z} = mp.players.local.getForwardVector()
    const {position} = mp.players.local;
    mp.game.graphics.drawLine(position.x, position.y, position.z, x, y, z, 255, 255, 255, 255);
});
</syntaxhighlight>
</syntaxhighlight>
}}
==See also==
==See also==
{{Graphics_s_function_c}}
{{Graphics_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 03:32, 28 May 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Draws a line bewteen the 2 vectors, colors and alpha are between 0 and 255. Must be called every frame.

Required Params

  • x1: number
  • y1: number
  • z1: number
  • x2: number
  • y2: number
  • z2: number
  • red: number
  • green: number
  • blue: number
  • alpha: number

Return value

  • void

Syntax

mp.game.graphics.drawLine(x1, y1, z1, x2, y2, z2, red, green, blue, alpha)

Example

//draw a line from player's position to their forward looking position
mp.events.add('render', () => {
    const {x, y, z} = mp.players.local.getForwardVector()
    const {position} = mp.players.local;
    mp.game.graphics.drawLine(position.x, position.y, position.z, x, y, z, 255, 255, 255, 255);
});


See also