Forum Replies Created
-
Well that’s Animator mechanism.
Try adding tracking property to Animator with an appropriate value. -
Make a separate technical text layer (“Array”) and apply this expression to sourceText:
var txt =thisComp.layer("Text").text.sourceText;
var regex = /\d[a-z]+(?=,)/g;function indexMatched(ind){
var matched = false;
var match;while ((match = regex.exec(txt)) !== null){
matched |= match.index
("Text" is the original text layer)Now its sourceText is smth like "0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0", each number representing a char in original text, 1=color, 0=not-to-color.
Make the "Array"'s duration 1 frame and convert expression to keyframes, so you can copy that "0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0".Next, change the expression in "Text" layer for the Expression Selector simply to:
arr = [0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0];
arr[textIndex-1] ? 100*selectorValue : 0;This will result in the same coloring as before but with less computations. Of cause, this workaround doesn't work, if "Text"'s sourceText changes in time.
BTW, all of these work well only for one-line texts, cause this code doesn't account for the fact that Selector doesn't count carriage return as a character, so coloring gets shifted by the number of lines. But I'm sure, there's some easy workaround for that.
-
Oleg Pirogov
April 1, 2019 at 11:04 pm in reply to: Building Expressions Workflow: multiple layers referencing single code?You may also look into eval() function, which allows you to interpret a string (say, sourceText of a text layer) as a code, so you can keep your code in a text layer an use it for each of 100 layers.
-
>Right but it would have to have a vector to figure out which way the blur should go
I don’t quite see why it needs the vector. In my understanding, Motion Blur just overlaps a number of rendered images of the layer mimicing real-life camera behavior rather than interpolates between frames.
>Did the OP ever post the project?
No not yet. Though you might be interested in recreating something similar by simply applying 10*timeToFrames(time); to, for instance, an X Position of some layer and turning on motion blur. I’m convinced it results in the same thing as in the OP’s project.
-
>Why did the code I wrote not work?
Well, color arrays in AE are arrays of numbers from 0 to 1 (at least, for 8bpc and 16bpc), i.e. Green=[0,1,0,1] and Yellow = [1,1,0,1]. So when you went from 100 to 99% you immediately switched from green to yellow. -
>The motion blur algorithm needs a delta between the frame before and the frame to come, neither of which are being calculated on the current frame.
As far as I understand it, motion blur just renders the layer at [Samples Per Frame (or more, up to Adaptive Sample Limit)] points in time taken uniformly(?) from the scope, defined by Shutter Angle and Phase. -
>But … do we know precisely what AE needs to compute a motion blur ?
>The position at every frame is clearly insufficient …
>The position at every thisComp.frameDuration/10 ? … thisComp.frameDuration/100 ??
Well, preferably, position at every point on the timeline. But since you have 16 Samples per Frame in the settings, ~16 discreet values per frame would arguably be enough.On the other hand, your speed is polynomial function of time:
-SpeedCoef*(tt-t0)*(tt-t1)
– why not just compute (I mean, with pen and paper) its primitive integral and use it instead of numerically integrating speed 16 times per frame? -
The code runs for each character each frame. If your text is huge, it might be the cause of your issue.
I suggest forming an array of indices of to-be-colored chars and keeping it a separate layer. This way you at least won’t have to run regex and the while cycle every time. -
I suggest dynamical creation of the second window(s):
var mw1 = new Window("palette", "Form1", undefined);
var mb1 = mw1.add ("button", undefined, "Button");
var mw2;
mw1.show();mb1.onClick = function myFun1(){
mw2 = new Window("palette", "Form2", undefined);
var mtx = mw2.add ("edittext",undefined, " ", {multiline: true});
mtx.preferredSize=[300,300];
var mb2 = mw2.add ("button", undefined, "Button2");mw2.show();
mb2.onClick = function myFun2(){
mw2.close();
if(mtx.text==0){alert ("No text!")}
else
{alert(mtx.text)}
}
} -
>Can someone tell me why?
Probably, cause Paper was parented to smth called Hand_L, which was not included to pre-comp, so Paper’s position switched to whatever. You would probably want to unparent it before pre-composing.