HU/dxDrawLine
Jump to navigation
Jump to search
Ez a function rajzol egy 2D-s vonalat a képernyőre - egy keretre. Ezt a onClientRender segítségével együtt kell használni annak érdekében, hogy folyamatosan jelenjen meg.
Szintaxis
bool dxDrawLine ( int startX, int startY, int endX, int endY, int color [, float width = 1.0, bool postGUI = false ] )
Kötelező paraméterek
- startX: An integer representing the absolute start X position of the line, represented by pixels on the screen.
- startY: An integer representing the absolute start Y position of the line, represented by pixels on the screen.
- endX: An integer representing the absolute end X position of the line, represented by pixels on the screen.
- endY: An integer representing the absolute end Y position of the line, represented by pixels on the screen.
- color: An integer of the hex color, produced using tocolor or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).
Tetszőleges paraméterek
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: The width/thickness of the line
- postGUI: A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
Visszatérési érték
Visszatérési értéke true, ha a művelet sikeres, egyébként false.
Példa
Ez a példa rajzol egy 'X'-et a képernyőre.
local screenWidth, screenHeight = guiGetScreenSize() local lineColor = tocolor(255, 0, 0) function drawLinesAcrossScreen() dxDrawLine(0, 0, screenWidth, screenHeight, lineColor) dxDrawLine(screenWidth, 0, 0, screenHeight, lineColor) end addEventHandler("onClientRender", root, drawLinesAcrossScreen)
This example draws a couple of circles
function drawCircle( x,y, radius, color ) local numPoints = math.floor( math.pow( radius, 0.4 ) * 5 ) -- Calculate number of points to make it look good local step = math.pi * 2 / numPoints local sx,sy for p=0,numPoints do local ex = math.cos ( p * step ) * radius local ey = math.sin ( p * step ) * radius if sx then dxDrawLine( x+sx, y+sy, x+ex, y+ey, color ) end sx,sy = ex,ey end end addEventHandler( "onClientRender", root, function() drawCircle( 350, 350, 10, tocolor(255,0,255) ); drawCircle( 350, 350, 50, tocolor(255,0,255) ); end )
Lásd még
- 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