- Documentation
- Shared functions
- interpolateBetween
Function
interpolateBetween
Smoothly moves from one set of three numbers to another (e.g. a position or a colour) by progress 0-1 and a curve like in getEasingValue. It also accepts two Vector3 vectors.
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])Arguments
x1float- First start number.
y1float- Second start number.
z1float- Third start number.
x2float- First end number.
y2float- Second end number.
z2float- Third end number.
fProgressfloat- Progress 0-1.
strEasingTypestring- The curve type.
fEasingPeriodfloat, optional- Period.
fEasingAmplitudefloat, optional- Amplitude.
fEasingOvershootfloat, optional- Overshoot.
Returns
Three in-between numbers.
Example
The colour changes from red to green over 2 seconds.
local start = getTickCount()
addEventHandler("onClientRender", root, function()
local p = math.min(1, (getTickCount() - start) / 2000)
local r, g, b = interpolateBetween(255, 0, 0, 0, 255, 0, p, "InOutQuad")
dxDrawRectangle(20, 300, 120, 20, tocolor(r, g, b))
end)