DgsCreateCustomRenderer

From Multi Theft Auto: Wiki
Revision as of 15:39, 28 April 2020 by Thisdp (talk | contribs)
Jump to navigation Jump to search

This function creates a custom renderer that can be used in any texture required property of dgs elements, which is useful for creating custom DGS plugins.

Syntax

element dgsCreateCustomRenderer( [ string renderFunction ] )

Optional Arguments

  • 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 a dgs-dxcustomrenderer element if successfully, false otherwise

Example

DGS = exports.dgs
local customRenderer = DGS:dgsCreateCustomRenderer([[
	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)
]] )
local tex = dxCreateTexture("exampleTexture.png") --Create a texture
local image = DGS:dgsCreateImage(300,300,200,200,customRenderer,false) --Apply the custom renderer
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