This is code from another language that i have translated. I have no idea what it's doing.
Seems to work well for rectangular shapes. Not so much for square shapes.
SetErrorMode(2)
// set window properties
SetWindowTitle( "Wobble Wobble" )
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( 14, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
logo = CreateObjectPlane(40, 11)
SetObjectImage(logo, LoadImage("logo.png"), 0)
SetObjectAlphaMask(logo, 1)
SetObjectTransparency(logo, 1)
frequency as float = 0.4
rfrequency as float = 0.4
angle as float = 0
rangle as float = 0
// store the original position so that the wobbling returns to the same place
sX as float = 0
sY as float = 0
size as float = 1.5
// diminish = 1 ... never stops wobbling, diminish >1 watch out!
diminish as float = 1
dir as float =.95
xscale as float = 1
yscale as float = 1
rotation as float
MoveCameraLocalZ(1, -50)
SetCameraPosition(1, 0, 0, GetCameraZ(1))
SetCameraLookAt(1, 0, 0, 0, 0)
do
s as float
// 2 things... increase angle by frequency, & calculate scale from cos of the result
inc angle, frequency
xscale = 100 + size * CosRad(angle) // _xscale = 100+size*Math.cos(angle += frequency);
// makes yscale same magnitude... opposite direction
yscale = 200 - xscale // _yscale = 200-_xscale;
// 2 things... increase rangle by rfrequency, & calculate rotation from cos of the result
inc rangle, rfrequency
rotation = size*CosRad(rangle)
SetObjectRotation(logo, 0, 0, rotation)
FixObjectPivot(logo)
SetObjectScale(logo, xscale / 100.0, yscale / 100.0, 1)
// wobbly move code
SetObjectPosition(logo, sX + size * CosRad(angle/2) / 10, sY + size * CosRad(rangle/2) / 10, 0)
// make size slightly less each frame - size is reset by clicking the button
size = size * diminish
Sync()
loop