dxDrawImage
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
Draws an image on the screen for a single frame. In order for the image to stay visible continuously, you need to call this function with the same parameters on each frame update (see onClientRender).
Image files should ideally have dimensions that are a power of two, to prevent possible blurring.
Power of two: 2px, 4px, 8px, 16px, 32px, 64px, 128px, 256px, 512px, 1024px...
To help prevent edge artifacts when drawing textures, set textureEdge to "clamp" when calling dxCreateTexture .
Do not draw image from path. Use a texture created with dxCreateTexture instead to efficiently draw image .
For further optimising your DX code, see dxCreateRenderTarget . You should use render target whenever possible, in order to dramatically reduce CPU usage caused by many dxDraw* calls.
Syntax
bool dxDrawImage ( float posX, float posY, float width, float height, mixed image, [ [ float rotation = 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, int color = tocolor(255,255,255,255 ] )Required Arguments
- posX: the absolute X coordinate of the top left corner of the image
- posY: the absolute Y coordinate of the top left corner of the image
- width: the absolute width of the image
- height: the absolute height of the image
- image: Either a material element or a filepath of the image which is going to be drawn. (.dds images are also supported). Image files should ideally have dimensions that are a power of two, to prevent possible blurring. Use a texture created with dxCreateTexture to speed up drawing .
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- float rotation (default: 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, int color = tocolor(255,255,255,255): MISSING_PARAM_DESC
Returns
- bool: value
Returns true if successful, false otherwise.
Code Examples
Example of a pendulum swinging from the top of the screen, made using dxDrawImage.
local screenWidth, screenHeight = guiGetScreenSize() -- Get screen resolution.local arrowTexture = dxCreateTexture('arrow.png')
function renderDisplay ( ) local seconds = getTickCount() / 1000 local angle = math.sin(seconds) * 80 -- This will draw the graphic file 'arrow.png' at the top middle of the screen -- using the size of 100 pixels wide, and 240 pixels high. -- The center of rotation is at the top of the image. dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, arrowTexture, angle, 0, -120 )endaddEventHandler("onClientRender", root, renderDisplay) -- Keep everything visible with onClientRender.See Also
Drawing Functions
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawModel3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsFormat
- dxGetPixelsSize
- dxGetStatus
- dxGetTextSize
- dxGetTexturePixels
- dxGetTextWidth
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetShaderValue
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource