DgsCreateMask

From Multi Theft Auto: Wiki

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

Multi Language Supports

Animation

3D Interface

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Grid List

Image

Memo

Label

Progress Bar

Radio Button

Scroll Bar

Scroll Pane

Selector

Switch Button

Tab Panel

Window

Plugin

Blur Box

Color Picker

Canvas

Effect 3D

Media Browser

Mask

Nine Slice

Object Preview Supports

QRCode

Remote Image

Rounded Rectangle