FORUMS: list search recent posts

Text Counter Connected to Layers Z-Rotation

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Doug Sand
Text Counter Connected to Layers Z-Rotation
on May 17, 2016 at 5:12:33 pm

I'm trying to build an analog meter with a digital text readout. Basically, I need the the source text to read out the rotational value of another layer. As you can see in the image, I want it to be able to read 0 when the needle is at 0, 1 when the needle is at 1 and so on and so forth.

All help is much appreciated!



Return to posts index

Xavier Gomez
Re: Text Counter Connected to Layers Z-Rotation
on May 17, 2016 at 5:41:46 pm

This might work:

minRot = -75;
maxRot = 75;
minValue = 0;
maxValue = 6;
rot = thisComp.layer("Shape Layer 3").transform.zRotation;
linear(rot, minRot, maxRot, minValue, maxValue);


Xavier


Return to posts index

Doug Sand
Re: Text Counter Connected to Layers Z-Rotation
on May 17, 2016 at 5:46:35 pm

Genius, genius, genius! One last question. What can I add to the code to keep the text to only two decimal points?



-Doug


Return to posts index


Xavier Gomez
Re: Text Counter Connected to Layers Z-Rotation
on May 17, 2016 at 6:46:04 pm

***If you want exactly 2 decimals, you can use:

... // same beginning
x = linear(rot, minRot, maxRot, minValue, maxValue);
x.toFixed(2);


***And if you want at most 2 decimals:

...
x = linear(rot, minRot, maxRot, minValue, maxValue);
Math.floor(x*100)/100;

Xavier


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]