2 CLASS(NexuizDecibelsSlider) EXTENDS(NexuizSlider)
3 METHOD(NexuizDecibelsSlider, loadCvars, void(entity))
4 METHOD(NexuizDecibelsSlider, saveCvars, void(entity))
5 METHOD(NexuizDecibelsSlider, valueToText, string(entity, float))
6 ENDCLASS(NexuizDecibelsSlider)
7 entity makeNexuizDecibelsSlider(float, float, float, string);
19 for(i = 1; i < 100; ++i)
36 for(i = 1; fabs(r - r0) >= 0.05; ++i)
38 // Newton iteration on exp(r) = x:
39 // r <- r - (exp(r) - x) / (exp(r))
40 // r <- r - 1 + x / exp(r)
42 r = r0 - 1 + x / exp(r0);
44 dprint("ln: ", ftos(i), " iterations\n");
49 #define LOG10 2.302585093
51 entity makeNexuizDecibelsSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
54 me = spawnNexuizDecibelsSlider();
55 me.configureNexuizSlider(me, theValueMin, theValueMax, theValueStep, theCvar);
58 void loadCvarsNexuizDecibelsSlider(entity me)
65 v = cvar(me.cvarName);
71 me.value = 0.1 * floor(0.5 + 10.0 * ln(cvar(me.cvarName)) * 10 / LOG10);
73 void saveCvarsNexuizDecibelsSlider(entity me)
79 cvar_set(me.cvarName, "1");
81 cvar_set(me.cvarName, "0");
83 cvar_set(me.cvarName, ftos(exp(me.value / 10 * LOG10)));
86 string valueToTextNexuizDecibelsSlider(entity me, float v)
92 return strcat(valueToTextSlider(me, v), " dB");