Decoder expression, linear to random resolution
I have an expression (pinched from an old creative cow post that in turn referenced a Dan Eberts expression) that decodes a string of text from a random selection of characters. It currently decodes the string from left to right and I need it to decode in a random order. Any ideas? Thanks in advance!
choices = "QAZWSXEDCRFVTGBYHNUJMIKOLP";
str = "this is my string";
tStart = 1; //time at which the animation starts
tStop = 2.4; //time at which the animation stop
cps = 0; // characters per second
if (time < tStart){
seed = Math.floor(time*cps);
seedRandom(seed,true);
s = "";
for (i = 0; i < str.length; i++){
idx1 = Math.floor(random(choices.length));
s += choices[idx1];
}
}
else if (time >= tStart && time < tStop){
seed = Math.floor(time*cps);
seedRandom(seed,true);
s = "";
sRand = "";
for (i = 0; i < str.length; i++){
idx1 = Math.floor(random(choices.length));
idx2 = Math.floor(linear(time,tStart,tStop,0,1)*str.length);
sRand += choices[idx1];
s = str.substr(0,idx2) + sRand.substr(idx2,str.length);
}
}else{
s = str;
}
s


