Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Decoder expression, linear to random resolution

Community Beginner ,
Apr 07, 2020 Apr 07, 2020

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

TOPICS
Expressions , Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 08, 2020 Apr 08, 2020

Most of the time trying to do everything on one layer over complicates a project. Here's a solution a little outside the box:

 

1.  Create a new text layer with your random characters

2.  Create a new text layer with your final text

3.  Create a new text layer with a symbol font to create a box for each letter

4.  Adjust the scale and tracking of all text layers to line up the boxes with the other two text layers (easiest to do using the difference blend mode

5.  Add Set Matte to the second and

...
Translate
LEGEND ,
Apr 08, 2020 Apr 08, 2020

You would have to modify the idx2 variable to also be based on randomness rather than just time, though then there would be no way to ensure that you don't get duplicate hits on the same letters and each of them is only used once. That in itself would require yet another loop to collect and exclude already used characters. All that said, why not simply use a wiggly text selector to add some randomness on top of the linear motion? Might look good enough and would be simpler to do. You could even go so far as to entirely ditch the source text expression and just work with text animators, though admittedly that in itself is hard to grasp and tricky to get right.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 08, 2020 Apr 08, 2020

This is essentially what I had been trying to do and failing miserably at!  Thanks for the response Mylenium.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2020 Apr 08, 2020

Random decoding of characters is much easier to do with text animators. You're making this much too difficult. There's even a decoder text preset that might get you started. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 08, 2020 Apr 08, 2020

The issue I was running into with text animator, and specifically the decoder preset, was that it uses character offset so still has spaces in the same places and still has the capitalization of the underlying text string.  I may not have delved deep enough however.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2020 Apr 08, 2020

Most of the time trying to do everything on one layer over complicates a project. Here's a solution a little outside the box:

 

1.  Create a new text layer with your random characters

2.  Create a new text layer with your final text

3.  Create a new text layer with a symbol font to create a box for each letter

4.  Adjust the scale and tracking of all text layers to line up the boxes with the other two text layers (easiest to do using the difference blend mode

5.  Add Set Matte to the second and third text layer and set the top symbol font text the source and invert one of the copies.

6.  Add the Random Fade In-text preset to the top layer

Here's what that looks like:

Screenshot_2020-04-08 12.22.49_VbFwgP.pngexpand imageScreenshot_2020-04-08 12.31.22_DFuo9J.pngexpand image

If you use Monospaced fonts this is incredibly easy and quick to set up. Much faster than monkeying with expressions. 

 

It took me about 10 minutes to do this. Here's the project file: https://www.dropbox.com/s/dchswxxyt8xsedh/Random%20Txt%20using%20mattes.aep?dl=0
(if your browser adds a .txt extension to the AEP file just delete it)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 08, 2020 Apr 08, 2020
LATEST

Thanks so much for this Rick!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines