interpolateBetween
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
Interpolates a 3D Vector between a source value and a target value using either linear interpolation or any other easing function. It can also be used to interpolate 2D vectors or scalars by only setting some of the x, y, z values and putting 0 to the others.
Syntax
float float float interpolateBetween ( float x1, float y1, float z1, float x2, float y2, float z2, float fProgress, string strEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot )Required arguments
- x1: MISSING_PARAM_DESC
- y1: MISSING_PARAM_DESC
- z1: MISSING_PARAM_DESC
- x2: MISSING_PARAM_DESC
- y2: MISSING_PARAM_DESC
- z2: MISSING_PARAM_DESC
- fProgress: float between 0 and 1 indicating the interpolation progress (0 at the beginning of the interpolation, 1 at the end). If it is higher than 1, it will start from the beginning.
- strEasingType: the easing function to use for the interpolation
- fEasingPeriod: the period of the easing function (only some easing functions use this parameter)
- fEasingAmplitude: the amplitude of the easing function (only some easing functions use this parameter)
- fEasingOvershoot: the overshoot of the easing function (only some easing functions use this parameter)
Returns
Returns x, y, z the interpolated 3D vector/value if successful, false otherwise (error in parameters). As mentioned before, interpolateBetween can be used on 2D vectors or scalars in which case only some (x, y or just x) of the returned values are to be used (cf. alpha interpolation in marker example or size interpolation in window example).
- float float float: value
Code Examples
This clientside example uses interpolateBetween to create position and color interpolation(with effect) on a marker. The command to test it is "/marker". The position is interpolated with "OutBounce" as strEasingType to make the marker bounce off the ground and "Linear" interpolation for the color.
local g_Marker = niladdCommandHandler("marker",function () if g_Marker then return end
local x, y, z = getElementPosition(getLocalPlayer()) z = z - 1
g_Marker = {} g_Marker.startPos = {x, y, z + 5} g_Marker.startTime = getTickCount() g_Marker.startColor = {255, 0, 0, 0} g_Marker.endPos = {x, y, z} g_Marker.endTime = g_Marker.startTime + 2000 g_Marker.endColor = {0, 0, 255, 255}
local x, y, z = unpack(g_Marker.startPos) local r, g, b, a = unpack(g_Marker.startColor) g_Marker.marker = createMarker(x, y, z, "cylinder", 1, 255, r, g, b, a)
addEventHandler("onClientRender", getRootElement(), popMarkerUp)end)
function popMarkerUp() local now = getTickCount() local elapsedTime = now - g_Marker.startTime local duration = g_Marker.endTime - g_Marker.startTime local progress = elapsedTime / duration
local x1, y1, z1 = unpack(g_Marker.startPos) local x2, y2, z2 = unpack(g_Marker.endPos) local x, y, z = interpolateBetween ( x1, y1, z1, x2, y2, z2, progress, "OutBounce")
setElementPosition(g_Marker.marker, x, y, z)
local r1, g1, b1, a1 = unpack(g_Marker.startColor) local r2, g2, b2, a2 = unpack(g_Marker.endColor) local r, g, b = interpolateBetween ( r1, g1, b1, r2, g2, b2, progress, "Linear") local a = interpolateBetween ( a1, 0, 0, a2, 0, 0, progress, "Linear")
setMarkerColor(g_Marker.marker , r, g, b, a)
if now >= g_Marker.endTime then removeEventHandler("onClientRender", getRootElement(), popMarkerUp) setTimer( function () destroyElement(g_Marker.marker) g_Marker = nil end, 3000, 1) 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