Differences From
Artifact [54a7601a0f]:
69 69 end
70 70 end
71 71
72 72 return string.format("%s%s", val, unit)
73 73 end
74 74
75 75 function fn.lerp(t, a, b) return (1-t)*a + t*b end
76 +function fn.gradient(grad, pos)
77 + local n = #grad
78 + if n == 1 then return grad[1] end
79 + local op = pos*(n-1)
80 + local idx = math.floor(op)
81 + local t = op-idx
82 + return fn.lerp(t, grad[1 + idx], grad[2 + idx])
83 +end
76 84
77 85 function fn.trim(fl, prec)
78 86 local fac = 10^prec
79 87 return math.floor(fl * fac) / fac
80 88 end
81 89
82 90 function fn.sign(v)