DxDrawRectangle
Jump to navigation
Jump to search
This function draws a 2D rectangle across the screen - rendered for one frame. This should be used in conjunction with onClientRender in order to display continuously.
Syntax
bool dxDrawRectangle ( int startX, startY, float width, float height [, int color = white, bool postGUI = false] )
Required Arguments
- startX: An integer representing the absolute origin X position of the rectangle, represented by pixels on the screen.
- startY: An integer representing the absolute origin Y position of the rectangle, represented by pixels on the screen.
- width: An float representing the width of the rectangle, 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.
Optional Arguments
- color: the color of the rectangle.
- postGUI: A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
Returns
Returns a true if the operation was successful, false otherwise.
Example
Click to collapse [-]
ClientExample of MOTD (message of the day), made using DxText, Line and Rectangle.
local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. local playerName = getPlayerName ( getLocalPlayer() ) -- Get players name. local MOTDText = "Welcome to our server, this is a test MOTD script for MTA's Wiki." -- Example of MOTD message. function create2DRectangle ( ) dxDrawRectangle ( x/2/2, y/2/2, x/2+40, y/2+40, tocolor ( 0, 0, 0, 150 ) ) -- Create our black MOTD background Rectangle. dxDrawText( "Welcome " .. playerName, x/2/2+41, y/2/2+32, x, y, tocolor ( 0, 0, 0, 255 ), 1.01, "pricedown" ) -- Create Welcome title shadow. dxDrawText( "Welcome " .. playerName, x/2/2+40, y/2/2+30, x, y, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Create Welcome title. dxDrawLine ( x/2/2+20, y/2/2+57, x/2/2+y/2+332, y/2/2+57, tocolor ( 0, 0, 0, 255 ), 3 ) -- Create underline shadow for title. dxDrawLine ( x/2/2+20, y/2/2+55, x/2/2+y/2+330, y/2/2+55, tocolor ( 255, 255, 255, 255 ), 2 ) -- Create underline for title. dxDrawText( MOTDText, x/2/2+40, y/2/2+80, x, y, tocolor ( 255, 255, 255, 255 ), 1, "clear" ) -- Create MOTD text. end function HandleTheRendering() addEventHandler("onClientRender",rootElement, create2DRectangle) -- Keep everything visible with onClientRender. end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering)
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource