getEasingValue
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
Used for custom Lua based interpolation, returns the easing value (animation time to use in your custom interpolation) given a progress and an easing function. In most cases, either moveObject or interpolateBetween can do the job. getEasingValue is only provided in case you want to do your own custom interpolation based on easing.
Syntax
getEasingValue ( )Code Examples
This clientside example uses getEasingValue to make a custom camera fade. The command to test it is "/fade". The fading out is done with "InQuad" to have a slow fading which then accelerates and "OutQuad" is used for fading in to have a smooth end of the fading. In this exampleinterpolateBetweencould have been used directly to interpolate the alpha between 0 and 255 and then 255 and 0 but is example is just to illustrate the use of getEasingValue by itself.
local g_Fade = niladdCommandHandler("fade",function () if g_Fade then return end g_Fade = {} g_Fade.startTime = getTickCount() g_Fade.endTime = g_Fade.startTime + 2000 g_Fade.easingFunction = "InQuad" --Slow at first and accelerating addEventHandler("onClientRender", getRootElement(), fadeCameraOut)end)
function fadeCameraOut() local now = getTickCount() local elapsedTime = now - g_Fade.startTime local duration = g_Fade.endTime - g_Fade.startTime local progress = elapsedTime / duration
local fAnimationTime = getEasingValue(progress, g_Fade.easingFunction)
local alpha = fAnimationTime*255 local width, height = guiGetScreenSize() dxDrawRectangle(0, 0, width, height, tocolor(0, 0, 0, alpha), true)
if now > g_Fade.endTime then removeEventHandler("onClientRender", getRootElement(), fadeCameraOut) g_Fade.startTime = getTickCount() g_Fade.endTime = g_Fade.startTime + 2000 g_Fade.easingFunction = "OutQuad" --Fast at first then decelerating addEventHandler("onClientRender", getRootElement(), fadeCameraIn) endend
function fadeCameraIn() local now = getTickCount() local elapsedTime = now - g_Fade.startTime local duration = g_Fade.endTime - g_Fade.startTime local progress = elapsedTime / duration
local fAnimationTime = getEasingValue(progress, g_Fade.easingFunction)
local alpha = (1-fAnimationTime)*255 local width, height = guiGetScreenSize() dxDrawRectangle(0, 0, width, height, tocolor(0, 0, 0, alpha), true)
if now > g_Fade.endTime then removeEventHandler("onClientRender", getRootElement(), fadeCameraIn) g_Fade = nil endendSee Also
Utility Functions
- addDebugHook
- bitAnd
- bitArShift
- bitExtract
- bitLRotate
- bitLShift
- bitNot
- bitOr
- bitReplace
- bitRRotate
- bitRShift
- bitTest
- bitXor
- createTrayNotification
- debugSleep
- decodeString
- deref
- downloadFile
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getFPSLimit
- getKeyboardLayout
- getLocalization
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getProcessMemoryStats
- getRealTime
- getServerIp
- getTickCount
- getTimerDetails
- getTimers
- gettok
- getUserdataType
- getVersion
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTimer
- isTimerPaused
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- ref
- removeDebugHook
- resetTimer
- setClipboard
- setDevelopmentMode
- setFPSLimit
- setTimer
- setTimerPaused
- setTransferBoxVisible
- setWindowFlashing
- sha256
- showCol
- showSound
- split
- teaDecode
- teaEncode
- tocolor
- toJSON
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub