DgsCustomRendererSetFunction

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function sets the render function of a dgs custom renderer.

Syntax

bool dgsCustomRendererSetFunction( element customRenderer, string renderFunction )

Required Arguments

  • customRenderer: A dgs custom renderer you want to set.
  • renderFunction: A string of lua code which will be the new renderer of the custom renderer.
    • Predefined Variable of renderFunction: For detail, see dxDrawImage
      • posX: Absolute X position of the renderer's bounding box.
      • posY: Absolute Y position of the renderer's bounding box.
      • width: Absolute width of the renderer's bounding box.
      • height: Absolute height of the renderer's bounding box.
      • self: The custom renderer itself.
      • rotation: The rotation of renderer's bounding box.
      • rotationCenterOffsetX: The rotation center offset x of renderer's bounding box.
      • rotationCenterOffsetY: The rotation center offset x of renderer's bounding box.
      • color: The color to be applied.
      • postGUI: Whether the dx draw is require postGUI

Returns

Returns true if successfully, false otherwise

Example

DGS = exports.dgs
local customRenderer = DGS:dgsCreateCustomRenderer() --Create an empty custom renderer
DGS:dgsCustomRendererSetFunction(customRenderer,[[
	local texture = dgsGetProperty(self,"customTexture")
	dxDrawImage(posX,posY,width,height,texture,rotation,rotationCenterOffsetX,rotationCenterOffsetY,color,postGUI)
	dxDrawImage(posX-width,posY-height,width,height,texture,rotation,rotationCenterOffsetX,rotationCenterOffsetY,color,postGUI)
]] ) -- We can set the function here
local tex = dxCreateTexture("exampleTexture.png") --Create a texture
local image = DGS:dgsCreateImage(300,300,200,200,customRenderer,false) --Apply the custom renderer
DGS:dgsSetProperty(customRenderer,"customTexture",tex) --Make a reference for the texture that can be used in the render function.
DGS:dgsAttachToAutoDestroy(tex,image) --The texture will be destroyed when the image destroys
DGS:dgsAttachToAutoDestroy(customRenderer,image) --The custom renderer will be destroyed when the image destroys

setTimer(function()
	destroyElement(image)
end,10000,1)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips