starlit  Diff

Differences From Artifact [988785061c]:

To Artifact [9f5dd95326]:


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

		if math.abs(val) > 1 then
			if uncommonScales or cmaj then
				local denom = 10^amt
				local vd = val/denom
				if prec then vd = lib.math.trim(vd, prec) end
				if math.abs(val) >= (10^(amt)) then
					return string.format("%s %s%s",
						vd, (full and pmaj or smaj), unit)
				end
			end
		elseif math.abs(val) < 1 then
			if uncommonScales or cmin then
				local denom = 10^-amt
				local vd = val/denom
				if prec then vd = lib.math.trim(vd, prec) end
				if math.abs(val) <= (10^-(amt-1)) then
					return string.format("%s %s%s",
						vd, (full and pmin or smin), unit)
				end
			end
		end
	end

	return string.format("%s %s", val, unit)
end

function fn.lerp(t, a, b) return (1-t)*a + t*b end

function fn.trim(fl, prec)
	local fac = 10^prec
	return math.floor(fl * fac) / fac







|
|








|
|





|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

		if math.abs(val) > 1 then
			if uncommonScales or cmaj then
				local denom = 10^amt
				local vd = val/denom
				if prec then vd = lib.math.trim(vd, prec) end
				if math.abs(val) >= (10^(amt)) then
					return string.format("%s%s%s",
						vd, (full and (' ' .. pmaj) or smaj), unit)
				end
			end
		elseif math.abs(val) < 1 then
			if uncommonScales or cmin then
				local denom = 10^-amt
				local vd = val/denom
				if prec then vd = lib.math.trim(vd, prec) end
				if math.abs(val) <= (10^-(amt-1)) then
					return string.format("%s%s%s",
						vd, (full and (' ' .. pmin) or smin), unit)
				end
			end
		end
	end

	return string.format("%s%s", val, unit)
end

function fn.lerp(t, a, b) return (1-t)*a + t*b end

function fn.trim(fl, prec)
	local fac = 10^prec
	return math.floor(fl * fac) / fac