DxDrawBorderedRectangle

From Multi Theft Auto: Wiki
Revision as of 15:47, 26 October 2016 by Conolel (talk | contribs) (Created page with " == Syntax == <syntaxhighlight lang="lua"> bool DxDrawBorderedRectangle( float x, float y, float width, float height, int color1, int color2, [int _width=1 if not used, postG...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Syntax

 bool DxDrawBorderedRectangle(  float x, float y, float width, float height, int color1, int color2, [int _width=1 if not used, postGUI = false ])

Required Arguments

  • x: An integer representing the absolute start X position of the line, represented by pixels on the screen.
  • y: An integer representing the absolute start Y position of the line, represented by pixels on the screen.
  • width: An float representing the width of the area, drawn in a right direction from the origin.
  • height: An float representing the height of the rectangle, drawn in a downwards direction from the origin.
  • color1: the hex color of the rectangle, produced using tocolor or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).
  • color1: the hex color of the lines, produced using tocolor or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • width: An integer representing how thick the lines will be.
  • postGUI: A bool representing whether the line should be drawn on top of or behind any ingame GUI.

Returns

Returns a true if the operation was successful, false otherwise.

Code

Click to collapse [-]
Clientside script
function DxDrawBorderedRectangle( x, y, width, height, color1, color2, _width, postGUI )
	local _width = _width or 1
	dxDrawRectangle(x+1, y+1, width-1, height-1, color1, postGUI)
	dxDrawLine ( x, y, x+width, y, color2, _width, postGUI ) -- Top
	dxDrawLine ( x, y, x, y+height, color2, _width, postGUI ) -- Left
	dxDrawLine ( x, y+height, x+width, y+height, color2, _width, postGUI ) -- Bottom
	return dxDrawLine ( x+width, y, x+width, y+height, color2, _width, postGUI ) -- Right
end

Example

This example draws a grey ractangle with a red lines



addEventHandler("onClientRender", root,
    function()
	DxDrawBorderedRectangle( 255, 350, 200, 100, tocolor(150,150,150,150),tocolor(250,0,0,150), 2, false )
    end
)


By : coNolel !