Haha! I translated your lua example. Thank you very much, it has been most helpful
// Project: test522
// Created: 20-06-01
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test522" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
SetClearColor(0x60, 0x60, 0x60)
SetVSync(1)
#constant PI 3.14159265359
i as integer
r as float
do
for i=0 to GetVirtualWidth()
select GetlastChar()
case asc("1")
r = GetVirtualHeight() - inQuad(i, 0, GetVirtualHeight(), GetVirtualWidth())
endcase
case asc("2")
r = GetVirtualHeight() - outQuad(i, 0, GetVirtualHeight(), GetVirtualWidth())
endcase
case asc("3")
r = GetVirtualHeight() - inCubic(i, 0, GetVirtualHeight(), GetVirtualWidth())
endcase
case asc("4")
r = GetVirtualHeight() - outCubic(i, 0, GetVirtualHeight(), GetVirtualWidth())
endcase
case default
r = GetVirtualHeight() - linear(i, 0, GetVirtualHeight(), GetVirtualWidth())
endcase
endselect
DrawEllipse(i, r, 1, 1, 0xffffffff, 0xffffffff, 1)
next
print("0-Linear")
print("1-InQuad")
print("2-OutQuad")
print("3-InCubic")
print("4-OutCubic")
print(str(GetLastChar()))
Sync()
loop
//
//Adapted from
//Tweener's easing functions (Penner's Easing Equations)
//and http://code.google.com/p/tweener/ (jstweener javascript version)
//
/*
Disclaimer for Robert Penner's Easing Equations license:
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright 2001 Robert Penner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- For all easing functions:
-- t = elapsed time
-- b = begin
-- c = change == ending - beginning
-- d = duration (total time)
*/
function linear(t as float, b as float, c as float, d as float)
r as float
r = c * t / d + b
endfunction r
function inQuad(t as float, b as float, c as float, d as float)
r as float
t = t / d
r = c * pow(t, 2) + b
endfunction r
function outQuad(t as float, b as float, c as float, d as float)
r as float
t = t / d
r = -c * t * (t - 2) + b
endfunction r
function inOutQuad(t as float, b as float, c as float, d as float)
r as float
t = t / d * 2
if t < 1
r = c / 2 * pow(t, 2) + b
else
r = -c / 2 * ((t - 1) * (t - 3) - 1) + b
endif
endfunction r
function outInQuad(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outQuad (t * 2, b, c / 2, d)
else
r = inQuad((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inCubic (t as float, b as float, c as float, d as float)
r as float
t = t / d
r = c * pow(t, 3) + b
endfunction r
function outCubic(t as float, b as float, c as float, d as float)
r as float
t = t / d - 1
r = c * (pow(t, 3) + 1) + b
endfunction r
function inOutCubic(t as float, b as float, c as float, d as float)
r as float
t = t / d * 2
if t < 1
r = c / 2 * t * t * t + b
else
t = t - 2
r = c / 2 * (t * t * t + 2) + b
endif
endfunction r
function outInCubic(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outCubic(t * 2, b, c / 2, d)
else
r = inCubic((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inQuart(t as float, b as float, c as float, d as float)
r as float
t = t / d
r = c * pow(t, 4) + b
endfunction r
function outQuart(t as float, b as float, c as float, d as float)
r as float
t = t / d - 1
r = -c * (pow(t, 4) - 1) + b
endfunction r
function inOutQuart(t as float, b as float, c as float, d as float)
r as float
t = t / d * 2
if t < 1
r = c / 2 * pow(t, 4) + b
else
t = t - 2
r = -c / 2 * (pow(t, 4) - 2) + b
endif
endfunction r
function outInQuart(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outQuart(t * 2, b, c / 2, d)
else
r = inQuart((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inQuint(t as float, b as float, c as float, d as float)
r as float
t = t / d
r = c * pow(t, 5) + b
endfunction r
function outQuint(t as float, b as float, c as float, d as float)
r as float
t = t / d - 1
r = c * (pow(t, 5) + 1) + b
endfunction r
function inOutQuint(t as float, b as float, c as float, d as float)
r as float
t = t / d * 2
if t < 1
r = c / 2 * pow(t, 5) + b
else
t = t - 2
r = c / 2 * (pow(t, 5) + 2) + b
endif
endfunction r
function outInQuint(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outQuint(t * 2, b, c / 2, d)
else
r = inQuint((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inSine(t as float, b as float, c as float, d as float)
r as float
r = -c * cos(t / d * (pi / 2)) + c + b
endfunction r
function outSine(t as float, b as float, c as float, d as float)
r as float
r = c * sin(t / d * (pi / 2)) + b
endfunction r
function inOutSine(t as float, b as float, c as float, d as float)
r as float
r = -c / 2 * (cos(pi * t / d) - 1) + b
endfunction r
function outInSine(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outSine(t * 2, b, c / 2, d)
else
r = inSine((t * 2) -d, b + c / 2, c / 2, d)
endif
endfunction r
function inExpo(t as float, b as float, c as float, d as float)
r as float
if t = 0
r = b
else
r = c * pow(2, 10 * (t / d - 1)) + b - c * 0.001
endif
endfunction r
function outExpo(t as float, b as float, c as float, d as float)
r as float
if t = d
r = b + c
else
r = c * 1.001 * (-pow(2, -10 * t / d) + 1) + b
endif
endfunction r
function inOutExpo(t as float, b as float, c as float, d as float)
r as float
if t = 0 : r = b : endif
if t = d : r = b + c : endif
t = t / d * 2
if t < 1
r = c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005
else
t = t - 1
r = c / 2 * 1.0005 * (-pow(2, -10 * t) + 2) + b
endif
endfunction r
function outInExpo(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outExpo(t * 2, b, c / 2, d)
else
r = inExpo((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inCirc(t as float, b as float, c as float, d as float)
r as float
t = t / d
r = (-c * (sqrt(1 - pow(t, 2)) - 1) + b)
endfunction r
function outCirc(t as float, b as float, c as float, d as float)
r as float
t = t / d - 1
r = (c * sqrt(1 - pow(t, 2)) + b)
endfunction r
function inOutCirc(t as float, b as float, c as float, d as float)
r as float
t = t / d * 2
if t < 1
r = -c / 2 * (sqrt(1 - t * t) - 1) + b
else
t = t - 2
r = c / 2 * (sqrt(1 - t * t) + 1) + b
endif
endfunction r
function outInCirc(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outCirc(t * 2, b, c / 2, d)
else
r = inCirc((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r
function inElastic(t as float, b as float, c as float, d as float, a, p as float)
r as float
s as float
if t = 0 : r = b : endif
t = t / d
if t = 1 : r = b + c : endif
if p = 0 : p = d * 0.3 : endif
local s
if a = 0 or a < abs(c)
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c/a)
endif
t = t - 1
r = -(a * pow(2, 10 * t) * sin((t * d - s) * (2 * pi) / p)) + b
endfunction r
// a: amplitud
// p: period
function outElastic(t as float, b as float, c as float, d as float, a, p as float)
r as float
s as float
if t = 0 : r = b : endif
t = t / d
if t = 1 : r = b + c : endif
if p = 0 : p = d * 0.3 : endif
local s
if a = 0 or a < abs(c)
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c/a)
endif
r = a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b
endfunction r
// p = period
// a = amplitud
function inOutElastic(t as float, b as float, c as float, d as float, a, p as float)
r as float
s as float
if t = 0 : r = b : endif
t = t / d * 2
if t = 2 : r = b + c : endif
if p = 0 : p = d * (0.3 * 1.5) : endif
if a = 0 : a = 0 : endif
if a = 0 or a < abs(c)
a = c
s = p / 4
else
s = p / (2 * pi) * asin(c / a)
endif
if t < 1
t = t - 1
r = -0.5 * (a * pow(2, 10 * t) * sin((t * d - s) * (2 * pi) / p)) + b
else
t = t - 1
r = a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p ) * 0.5 + c + b
endif
endfunction r
// a: amplitud
// p: period
function outInElastic(t as float, b as float, c as float, d as float, a as float, p as float)
r as float
if t < d / 2
r = outElastic(t * 2, b, c / 2, d, a, p)
else
r = inElastic((t * 2) - d, b + c / 2, c / 2, d, a, p)
endif
endfunction r r
function inBack(t as float, b as float, c as float, d as float, s)
r as float
if not s : s = 1.70158 : endif
t = t / d
r = c * t * t * ((s + 1) * t - s) + b
endfunction r r
function outBack(t as float, b as float, c as float, d as float, s)
r as float
if not s : s = 1.70158 : endif
t = t / d - 1
r = c * (t * t * ((s + 1) * t + s) + 1) + b
endfunction r
function inOutBack(t as float, b as float, c as float, d as float, s)
r as float
if not s : s = 1.70158 : endif
s = s * 1.525
t = t / d * 2
if t < 1
r = c / 2 * (t * t * ((s + 1) * t - s)) + b
else
t = t - 2
r = c / 2 * (t * t * ((s + 1) * t + s) + 2) + b
endif
endfunction r
function outInBack(t as float, b as float, c as float, d as float, s)
r as float
if t < d / 2
r = outBack(t * 2, b, c / 2, d, s)
else
r = inBack((t * 2) - d, b + c / 2, c / 2, d, s)
endif
endfunction r
function outBounce(t as float, b as float, c as float, d as float)
r as float
t = t / d
if t < 1 / 2.75
r = c * (7.5625 * t * t) + b
elseif t < 2 / 2.75
t = t - (1.5 / 2.75)
r = c * (7.5625 * t * t + 0.75) + b
elseif t < 2.5 / 2.75
t = t - (2.25 / 2.75)
r = c * (7.5625 * t * t + 0.9375) + b
else
t = t - (2.625 / 2.75)
r = c * (7.5625 * t * t + 0.984375) + b
endif
endfunction r
function inBounce(t as float, b as float, c as float, d as float)
r as float
r = c - outBounce(d - t, 0, c, d) + b
endfunction r
function inOutBounce(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = inBounce(t * 2, 0, c, d) * 0.5 + b
else
r = outBounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b
endif
endfunction r
function outInBounce(t as float, b as float, c as float, d as float)
r as float
if t < d / 2
r = outBounce(t * 2, b, c / 2, d)
else
r = inBounce((t * 2) - d, b + c / 2, c / 2, d)
endif
endfunction r