-
Selecting specific Function depending on two sliders
Hi,
I’ve got a good number of easing functions and they’re named like so:
inoutQuint()
inQuint()
outQuint()I’d like to switch between functions with two sliders, one for ease type (i.e. Quint) and another for which sided easing I want (i.e. out).
What would be the best way to choose the function using those two sliders? I tried constructing a switch statement like so:
switch (easeSelect) {
case 1:
ease = "Sine";
break;
case 2:
ease = "Quad";
break;
case 3:
ease = "Quart";
break;
case 4:
ease = "Quint";
break;
case 5:
ease = "Circ";
break;
case 6:
ease = "Expo";
break;
case 7:
ease = "Bounce";
break;
case 8:
ease = "Back";
break;
case 9:
ease = "Elastic";
break;
default:
return null;
}switch (easeType) {
case 1:
easeType = "in";
break;
case 2:
easeType = "out";
break;
case 3:
easeType = "inout";
break;
default:
return null;
}The problem is that I can’t construct a function out of that as the ease and easeType are string variables so something like this doesn’t work:
var func = easeType + ease;Is there any other way to go around this apart from nested switches?
Cheers,
PJ————————————————–
Freelance Cinematographer, Camera Op, Video Editor and Motion Graphics Designer