DgsAnimTo

From Multi Theft Auto: Wiki

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,[ function callBack = nil, bool reverseProgress = false ] )

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 dgsAddEasingFunction.
  • duration: The time(ms) to finish the animation.

Optional Arguments

  • callBack: The call back function ( Unable to use outside of DGS resource )
  • reverseProgress: Would you like the progress go from 0 to 1 or go from 1 to 0?

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
	-- setting: a table {propertyName,targetValue,initialValue}
	-- self: the dgs element
	-- propertyTable: property table of the dgs element
		local _b,_g,_r,_a = bitExtract(setting[3],0,8),bitExtract(setting[3],8,8),bitExtract(setting[3],16,8),bitExtract(setting[3],24,8)
		local b,g,r,a = bitExtract(setting[2],0,8),bitExtract(setting[2],8,8),bitExtract(setting[2],16,8),bitExtract(setting[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

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

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