DgsCreateCanvas: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function creates a canvas that is used to draw multiple shaders. ==Syntax== <syntaxhighlight lang="lua"> element dgsCreateCanvas( elemen...")
 
(Remove unused color)
 
Line 6: Line 6:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dgsCreateCanvas( element renderSource, int width, int height [, int color ] )
element dgsCreateCanvas( element renderSource, int width, int height )
</syntaxhighlight>  
</syntaxhighlight>  


Line 13: Line 13:
*'''width:''' An integer indicates the width of canvas.
*'''width:''' An integer indicates the width of canvas.
*'''height:''' An integer indicates the height of canvas.
*'''height:''' An integer indicates the height of canvas.
===Optional Arguments===
*'''color:''' A integer of the color of the canvas.


===Returns===
===Returns===

Latest revision as of 10:34, 29 June 2023

This function creates a canvas that is used to draw multiple shaders.

Syntax

element dgsCreateCanvas( element renderSource, int width, int height )

Required Arguments

  • renderSource: The source to draw on the canvas, can be material such as texture, render target, shader etc.
  • width: An integer indicates the width of canvas.
  • height: An integer indicates the height of canvas.

Returns

Returns a dgs-dxcanvas element (DGS Plugin Type)[ render target (Element Type) ] if succeed, false otherwise

Example 1

DGS = exports.dgs --get exported functions from dgs

local QRCode = DGS:dgsRequestQRCode("https://wiki.multitheftauto.com/wiki/Resource:Dgs") --Source Texture
local mask1 = DGS:dgsCreateMask(QRCode,"circle") --Apply Source Texture to Mask 1
local canvas = DGS:dgsCreateCanvas(mask1,200,200) --Draw Mask 1 in Canvas
local mask2 = DGS:dgsCreateMask(canvas ,"backgroundFilter") --Apply Canvas to Mask 2
local image = DGS:dgsCreateImage(300,300,200,200,mask2 ,false) --Draw Mask 2

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