DgsCreateMask: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 9: Line 9:
</syntaxhighlight>  
</syntaxhighlight>  


[[Image:DGS_Removed_BG_QRCode.png|256px|thumb|Example QRCode with background color removed]]
[[Image:DGS_Removed_BG_QRCode.png|128px|thumb|Example QRCode with background color removed]]
===Required Arguments===
===Required Arguments===
*'''sourceTexture: ''' A texture you want to be masked.
*'''sourceTexture: ''' A texture you want to be masked.
Line 32: Line 32:
Returns a dgs-dxmask element (DGS Plugin Type)[ shader (Element Type) ] if succeed, ''false'' otherwise
Returns a dgs-dxmask element (DGS Plugin Type)[ shader (Element Type) ] if succeed, ''false'' otherwise


==Example==  
==Example 1==
This example shows texture masked texture.
<syntaxhighlight lang="lua">
DGS = exports.dgs --get exported functions from dgs
 
local sourceTex = dxCreateTexture("tex1.png")  -- Your Texture
local maskTex= dxCreateTexture("tex2.png")  -- Your Mask ( You'd better use black&white texture )
local mask = DGS:dgsCreateMask(sourceTex,maskTex)
local image = DGS:dgsCreateImage(300,300,200,200,mask,false)
</syntaxhighlight>
 
==Example 2==  
This example shows a QRCode without background .
This example shows a QRCode without background .
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Latest revision as of 08:42, 9 February 2020

This function creates a DGS mask.

Syntax

element dgsCreateMask( texture sourceTexture, texture/shader/string mask [, table settings ] )
Example QRCode with background color removed

Required Arguments

  • sourceTexture: A texture you want to be masked.
  • mask: A texture/shader/string(built-in mask) of the mask. Built-in masks are as follows:
    • circle: Make source texture a circle. Here is the settings:
offset = { offsetX, offsetY, relative } -- Offsets of the source texture
scale = { scaleX, scaleY, relative } -- Scale of the source texture
radius = radius -- The radius of the mask shader which ranges from 0 to 0.5 (recommended)
    • backgroundFilter: Remove specific color with specific range from the texture. Here is the settings:
filterRGB = {R,G,B} -- The color you want to remove.
filterRange = filterRange -- The color range
isPixelated = isPixelated -- whether the texture should be pixelated like MineCraft or smooth scaled.

Optional Arguments

  • settings: A table of the settings of mask (specified by mask type).

Returns

Returns a dgs-dxmask element (DGS Plugin Type)[ shader (Element Type) ] if succeed, false otherwise

Example 1

This example shows texture masked texture.

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

local sourceTex = dxCreateTexture("tex1.png")  -- Your Texture
local maskTex= dxCreateTexture("tex2.png")  -- Your Mask ( You'd better use black&white texture )
local mask = DGS:dgsCreateMask(sourceTex,maskTex)
local image = DGS:dgsCreateImage(300,300,200,200,mask,false)

Example 2

This example shows a QRCode without background .

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

local QRCode = DGS:dgsRequestQRCode("https://wiki.multitheftauto.com/wiki/Resource:Dgs")
local mask = DGS:dgsCreateMask(QRCode,"backgroundFilter",{
	filterRGB={255,255,255},
	filterRange=0.01,
	isPixelated=true,
})
local image = DGS:dgsCreateImage(300,300,128,128,mask,false)

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