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

Random Color by TextIndex

New Here ,
Jun 11, 2021 Jun 11, 2021

Hi Folks, 

 

I've got my brain in a twist trying to figure out an expression and I've ran out of time. 

I have a 2 text layers (each a different colour) with a few thousand letters of DNA code. I want to overlay them to show 'blending the two codes' together. 

 

My approach is use an expression on an opacity animator. The expression would randomly make each character either invisible or visible, so about 50% is randomly hidden ( as gaps in the code ). I cannot figure out how to use textindex to do this. 

 

If I do this on one text layer to hide half the characters, is it possible to use something like a seedvalue to make the exact opposite characters hidden/visible on text 2. I.e toi flip the visiblility of each character. That way, I can overlay the two text layers and the visible characters of text 1 would overlap the invisible character of text 2, thus making the DNA code complete again

 

Any help greatly appreciated. 

TOPICS
Expressions
666
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
LEGEND ,
Jun 11, 2021 Jun 11, 2021

Not really. That's basically where you run into the limitations of expressions. In order to be reproducible, the values would need to be stored somewhere and accessible by both layers, meaning an array or a string on a third text layer, with all the extra code that requires to fetch the data. There's also no guarantee that there's ever actually only 50 % of the letters visible based on simple random functions. That being the case, it might in fact be simpler to just construct the complete string from scratch in the source text, including using spaces for gaps. This is basically similar to the "random binary code" tutorials that were all the rage 15 years ago. Modifying such an example should be easy enough and your matching base pairs would simply be created by reversing the order of the letters in the source array function.

 

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
New Here ,
Jun 11, 2021 Jun 11, 2021

Thanks for the reply! The binary code thing has got me a lot closer. I found an old tutorial that used the WiggleSelector instead of the Expression Selector. 

 

This has almost worked. The only problem is that the wiggle selector has a range of -100 to 100, and everything in between... so I get half or part faded characters. On the plus side, if I flip -100 to 100 into 100 to -100, the effect is exactly opposite, just like I wanted.

 

The only question now is, is their a way to constain this selector so that only the extreme values of -100 or 100 are used and nothing in between?

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
LEGEND ,
Jun 11, 2021 Jun 11, 2021

Try clipping the values with an adjustment effect like Levels or Threshold set to the Alpha/ Opacity channel. Alternatively you could even use a color fill animator with this method and tweak the colors that way, then use the result as am the/ inverted matte. Especially if you plan adding more fancy treatments this could even be more efficient than having to use multiple text layers.

 

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
New Here ,
Jun 11, 2021 Jun 11, 2021

Thanks. I'm afraid I don't understad what you mean. 

 

I tried adding an expression selector to the chain after the wiggly selector, hoping I could use the output of the wigglySelector in an if else statement on the expression selector i.e

if (selectorValue < x) {0} else {100}

 

where x is the half way between the min max outputs of the wiggly selector. 

 

But:

a) I don't know what x should be and

b) it doesn't seem to apply the effect on a per character basis like the documentation said, either all the characters turn one colour or they all turn the other colour. 

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
New Here ,
Jun 11, 2021 Jun 11, 2021
LATEST

Cracked it. 

 

For anyone else, I did this. Just create an expression selector and use seedRandom with an if else statement, like this: 

val = [0,100]
seedRandom(textIndex, timeless=true)
x = random(100)
if (x<50) {0} else {100}

To reverse it, just swap {0} and {100}

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