- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.lua
More file actions
Latest commit
71 lines (64 loc) · 1.74 KB
/
Copy pathutils.lua
File metadata and controls
71 lines (64 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
functionsafeIndex(t, ...)
for_, kinpairs({...}) do
iftype(t) ~='table' thenreturnnilend
t=t[k]
end
returnt
end
functionlerpAngle(a, b, t)
localtheta=b-a
iftheta>math.pithen
a=a+2*math.pi
elseiftheta<-math.pithen
a=a-2*math.pi
end
returnlume.lerp(a, b, t)
end
functionhash(x)
localz=math.sin(x)*43758.5453
returnz-math.floor(z)
end
functionhash2(x, y)
localz=math.sin(x*12.9898+y*78.233)*43758.5453
returnz-math.floor(z)
end
ease= {
inQuad=function (t) returnt*tend,
outQuad=function (t) returnt*(2-t) end,
inOutQuad=function (t) returnt<0.5and2*t*tor-1+(4-2*t)*tend,
inCubic=function (t) returnt*t*tend,
outCubic=function (t) returnmath.pow(t-1,3)+1end,
inOutCubic=function (t) returnt<0.5and4*t*t*tor (t-1)*(2*t-2)*(2*t-2)+1end,
inQuart=function (t) returnt*t*t*tend,
outQuart=function (t) return1-math.pow(t-1,4) end,
inOutQuart=function (t) returnt<0.5and8*math.pow(t,4) or1-8*math.pow(t-1,4) end,
inQuint=function (t) returnt*t*t*t*tend,
outQuint=function (t) return1+math.pow(t-1,5) end,
inOutQuint=function (t) returnt<0.5and16*math.pow(t,5) or1+16*math.pow(t-1,5) end
}
functionbuildName(name, postfix)
returnname.. (postfix~=0and'(' ..postfix..')' or'')
end
functionisort(_t, comp, rev)
ifcomp==nilthen
comp=function(a, b) returna<bend
elseiftype(comp) ~='function' then
localk=comp
comp=function(a, b) returna[k] <b[k] end
end
ifrevthen
_comp=comp
comp=function(a, b) returnnot_comp(a, b) end
end
localt= {}
fori=1, #_tdo
localv=_t[i]
localj=i-1
whilej>0andnotcomp(t[j], v) do
t[j+1] =t[j]
j=j-1
end
t[j+1] =v
end
returnt
end