LyMath - Ly Framework - Gamely

A huge numebr of math functions to complement crayta Api.
Many functions are made for animation with support for easing curves and functions to mix , modify and chain them together.
To access it from every script using Ly.Math LyFramework with properly setupped LyRequire is needed.
After installing you need to add it to LyFramework subfolder lib see LyRequire Documentation.

converts radians to degrees

converts degrees to radians

continuous sin curve -1 to 1 more conventient than simple sin as it loops at integer values.

same as sin but offsetted using cos in place of sin cosByRate(0) == sinByRate(0.25)
more conventient than simple cos as it loops at integer values.

snaps to the nearest multiple of 1 / by

snaps to the nearest multiple of to

map(val, fromMin, fromMax, toMin, toMax)
remaps ranges from to

fitTo01(val, min, max)
it clamps to min and max and maps to 0 1


hsl2Color(h, s, l, a)
convert hsl color to Color hsl is more flexible in animation than rgb

Easing in out and InOut for
sin, quad, cubic quartic , quintic , expo , circ , back, bounce, elastic

local m = Ly.Math
local newZ = m.lerp(startZ, endZ, m.backInOut(t)) 

Anim and Interpolation Modifiers.

  • lerp(t, from, to) – include due to different args order and to ease jit inlining, but you can still use math.lerp(from, to, t)
  • inverseLerp(val, from, to)
  • loop(t, from, to)
  • shake(rate, center, [rndFunc = math.random])
  • mix(t, f1, f2, [w = 0.5])
  • crossFade(t, f1, f2, wf, w1, w2)
  • chain(t, f1, f2, mergePoint, mergeValue)
  • switch(t, f1, f2, [switchPoint = 0.5])
  • yoyo(t, f)
  • zigzag(t, f)
1 Like

I want to change toDeg and toRad from functions to constants you then need to multiply with the number to convert.

I also plan to remove revert as it’s of very little use it’s just 1 - value.

Removed blend as it was equal to mix.