Stephen Dixon
Forum Replies Created
-
David, the square brackets turn the number into an array. Why do this? You’re converting to an array and then forcing the expressions engine to convert the array into an integer, which could lead to problems.
The curly brackets form part of the if – else expression:if(condition){code block} else if (condition){code block} else {code block}You use them when there is more than one line in the block of code that gets executed if the condition is true or false. Older versions of the syntax required them for all if-then expressions, so you can use them for single line blocks without a problem.
Curly brackets or square brackets have nothing to do with returning a value from an expression, they’re part of JS syntax.
-
Stephen Dixon
September 25, 2020 at 1:29 am in reply to: maintaining stroke width of all elements, while scaling the MAIN COMPlink the stroke width via expressions to the scale of the precomp in the outer comp.
E.g. apply this to the stroke width:
let s = comp(“outer comp name”).layer(thisComp.name).transform.scale;
100/s[0] * valuereplace “outer comp name” with the name of the comp that contains the precomp. As the scale increases the stroke width will decrease, for example if the scale (represented by the variable s) is 200 then 100/s will equal 0.5, and conversely if the scale is 50 the 100/s = 2. Note that this will cause errors if the scale goes to zero, so you could add a try() to catch the error e.g., this will clamp it to 1000 × the current value
let s = comp(“outer comp name”).layer(thisComp.name).transform.scale;
try {
Math.min(100/s[0], 1000) * value;
} catch (err){
1000 * value
} -
Stephen Dixon
September 25, 2020 at 12:53 am in reply to: Variable 2nd position keyframe. (first one is locked)Using an interpolation function like linear() will allow you to transition from one value to another over time. E.G.:
let kf1 = transform.position.key(1);
let kf2 = transform.position.key(2);
linear(kf1.time, kf2.time, kf1.value, [sliderVal, kf2.value[1]])You could also use ease(), easeIn() or easeOut() in place of linear, for smoothly eased motion.
-
Maddeningly AE layer indexes start at 1, not zero, so any loops that reference indexes have to start at 1. That could be your problem. Either that or for some reason you’re trying to reference a layer index that doesn’t exist.
Also
parseInt((thisLayer.index)-2 //**Works correctly
How can this work correctly? You’re missing a bracket on the right hand side, and parseInt is for converting strings into ints.
-
Those expressions you posted both do what you want, they turn the sound on and off with markers. But I’m guessing when you say on and off, maybe you want the sound to start at one marker and end at the other? If so use the second expression, but invert the logic—it currently turns the audio OFF if the current time is between two markers, so you want to do the opposite; turn the audio ON if the time is between two markers.
To invert the logic you could either swap the contents of the curly brackets (the two lines starting with ease…) or add a logical not to the if() using the javascript notation !. in other words, line 4 should be if(! m.index%2){
-
Stephen Dixon
November 16, 2016 at 11:47 pm in reply to: Double checking : AE raster-based ? If yes, how to preserve appearance of small contents ?I don’t understand how this would help. If your final resolution is fixed, blowing up the comp will just create extra render time, and then the pixels will have to be reinterpolated back to the final resolution.
Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria -
Stephen Dixon
November 11, 2016 at 12:28 am in reply to: Double checking : AE raster-based ? If yes, how to preserve appearance of small contents ?I think part of the problem is that it sounds like the assets aren’t really suitable for video. A 1 pixel line will only look good when it is aligned perfectly with the pixel grid. Any other position and the edges will have to be interpolated, and since it’s only 1 pixel that means all of it will be interpolated.
Think about if it’s moved on X half a pixel. How do you rasterise a 1 pixel line that’s halfway between two columns of the pixel grid?
Can you really not afford to make it 2 pixels wide?
Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria -
Stephen Dixon
November 9, 2016 at 1:42 am in reply to: Double checking : AE raster-based ? If yes, how to preserve appearance of small contents ? -
use Cassius’s expression for each group of numbers, and then join them together by simply adding them. So say you have two sliders, one for seconds and one for minutes (is that what you’re doing?):
sec = Math.round(effect("Slider Control")("Slider")).toFixed(0);
while (sec.length < 2) sec = "0" + sec;
min= Math.round(effect("Slider Control")("Slider 2")).toFixed(0);
while (min.length < 2) min = "0" + min;
min + ":" + secStephen Dixon
Editor, Animator, Motionographer
Museum Victoria -
Stephen Dixon
November 9, 2016 at 1:15 am in reply to: Double checking : AE raster-based ? If yes, how to preserve appearance of small contents ?You need to use the “collapse transforms” checkbox. What that does is hold off rasterising the nested comps until the outer comp is rasterised. There’s a good tutorial about collapse transformations here, and you can read the adobe docs here. It can be a little bit tricky to get your head around.
To answer your first question, yes, ultimately AE is ultimately raster based, because it produces video, and video is a raster based format (unless of course you’re exporting to flash). But within that it does have support for vectors, both natively with its built-in vector tools, and externally such as support for illustrator files. What you need to manage is when the rasterisation occurs, which is what the collapse transformations switch is for.
Say you have your vector-based boat layer nested within a comp (we’ll call it the outer comp). If you have collapse transformations off (as it is by default) and you scale the boat comp in the outer comp, it will treat the nested comp as if it were a rendered raster image, so the pixels in the mast will be interpolated, meaning fuzzies. If however you turn collapse transformations on the boat will stay a vector layer until after the scaling done in the outer comp meaning that the lines will be as crisp as the outer comp’s resolution allows. Does that make sense? Rule of thumb: most of the time if you’re using vector images in precomps, turn on collapse transformations.
Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria
