DgsAnimTo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function allow us to add animation to dgs elements. Change any property of dgs elements with animation effect. ==Syntax== <syntaxhighligh...")
 
Line 6: Line 6:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
gui,property,value,easing,thetime
bool dgsAnimTo ( element dgsElement, string propertyName, mixed value, string easing = "Linear", int duration )
bool dgsAnimTo ( element dgsElement, string propertyName, mixed value, string easing = "Linear", int duration )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 02:32, 10 June 2018

This function allow us to add animation to dgs elements.

Change any property of dgs elements with animation effect.

Syntax

bool dgsAnimTo ( element dgsElement, string propertyName, mixed value, string easing = "Linear", int duration )

Required Arguments

  • dgsElement: The DGS element to set animation to.
  • propertyName: The property you want to apply to,
  • value: Target value (should be a number when using built-in easing functions)
  • easing: The easing function to use for the interpolation (For More Detail :Easing), or your own easing function created by addEasingFunction.
  • duration: The time(ms) to finish the animation.

Returns

Returns true if succeed, false otherwise.

Example

DGS = exports.dgs

if not DGS:dgsEasingFunctionExists("colorChange") then
	DGS:dgsAddEasingFunction("colorChange",[[
	--Predefined variable
	-- progress: from 0 to 1 , indicates the progress of the whole animation
	-- settings: a table {propertyName,targetValue,initialValue}
	-- self: the dgs element
	-- propertyTable: property table of the dgs element
		local _r,_g,_b,_a = bitExtract(settings[3],0,8),bitExtract(settings[3],8,8),bitExtract(settings[3],16,8),bitExtract(settings[3],24,8)
		local r,g,b,a = bitExtract(settings[2],0,8),bitExtract(settings[2],8,8),bitExtract(settings[2],16,8),bitExtract(settings[2],24,8)
		return tocolor(_r+(r-_r)*progress,_g+(g-_g)*progress,_b+(b-_b)*progress,_a+(a-_a)*progress)
	]])
end

image = DGS:dgsCreateImage(200,100,400,400,_,false,_,tocolor(0,0,0,255))
DGS:dgsAnimTo(image,"color",tocolor(200,100,50,255),"colorChange",5000)

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