Expressions and Tips

From bernie's
Jump to: navigation, search

azerty AFX keyboard shortcuts


Rand characters

chars = "GATC";
textValue = "";
for(i=0;i<100;i++){
	randVar = random() * chars.length;
	characterVar = chars.charAt(randVar);
	textValue = textValue + characterVar;
}
textValue;

Current Keyframe Index

//gobelins
a = timeRemap;
nk = a.nearestKey(time);
curframe = 0;
if(nk.time > time){
	curframe = nk.index-1;
}else{
	curframe = nk.index;
}
curframe*thisComp.frameDuration;

fa2262be189547b5381aa50041cdc32b.gif

a = position;  //or whatever animated property
nk = a.nearestKey(time);

if(nk.time > time){
	nk.index-1;
}else{
	nk.index;
}

sample image pr les gobz

a = sampleImage([thisComp.width/2,thisComp.height/2], [thisComp.width/2,thisComp.height/2], postEffect = true, t = time);
a[0]+a[1]+a[2]+a[3];



////bake


v = effect("s")("Curseur")-effect("s")("Curseur").valueAtTime(time-1/25)==0?0:1

//////bake?

v = effect("hold")("Curseur");
a = 0;
for(i=0;i<=time*25;i++){
	if(v.valueAtTime(i/25)==1){
		a = i/25;
	}
}
a;

spread thingy

dlJJcXt.gif

p = thisComp.layer("Null 1").transform.position;
delta = transform.position - p;
amplitude = thisComp.layer("Null 1").effect("amplitude")("Slider");
reach = thisComp.layer("Null 1").effect("reach")("Slider");
exponent = thisComp.layer("Null 1").effect("exponent")("Slider")

length = (length(delta));
if(length>0){
	transform.position += normalize( delta ) *  ( reach / Math.pow(length, exponent)  ) * amplitude;
}else{
	transform.position = [-2000,0]
}

Sprites

Duplicate layers by hand, add CtrlNul, offsetLeftRight, offsetDepth, spread sliders

//POSITION
seedRandom(index,true)
ctrl = thisComp.layer("CtrlNul");
dist = ctrl.effect("dist")("Slider");
offset = [ctrl.effect("offsetLeftRight")("Slider"),0,ctrl.effect("offsetDepth")("Slider")];

depthjitter = ctrl.effect("depthjitter")("Slider");
depthmult = ctrl.effect("depthmult")("Slider");
spread = ctrl.effect("spread")("Slider");

dist = dist+random()*spread;

transform.position+[(index%2)?-dist:dist,0,depthmult*index+depthjitter*random()]+offset



//ORIENTATION
lookAt(transform.position,thisComp.layer("Camera 1").transform.position)

Write on effect

091522309c14c61f0cc7d63672e78900.gif

fps = 1/thisComp.frameDuration;
cursorSpeed = 3;
text.sourceText.slice(0,time*fps)+((Math.floor(time*cursorSpeed)%2)?"|":" ");

Unscramble wip

k8Gf1wC.gif

wordspeed = time/1; //or a slider, or whatever
letterspeed = time*2;
txt = text.sourceText;
txtVar = "";
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
splitxt = txt.split("\r");
maxLines = Math.min(splitxt.length-1, Math.floor(wordspeed));
for(i=0;i<=maxLines;i++){
	txtVar += (i>0)?splitxt[i-1]+"\r":"";
	len = splitxt[i].length;
	if(i == maxLines){
		for(j=0;j<=len-1;j++){
			txtVar += (j/len>=wordspeed-Math.floor(wordspeed))?chars.charAt(random()*chars.length):splitxt[i].charAt(j);
		}
	}
}
txtVar
;

Poor man's padding

//for lack of a cleaner version, up to 4 digits
a = time*25;
a=(a<10)?"000"+a:((a<100)?"00"+a:((a<1000)?"0"+a:a));

2d lookat

LookAt = "ball"
offset = 0
diffx = position[0] - this_comp.layer(LookAt).position[0];
diffy = position[1] - this_comp.layer(LookAt).position[1];
if (diffx == 0) {
diffx = 1 }
sign = 1 + (-1 * (diffx / Math.abs(diffx))) * 90;
radians_to_degrees(Math.atan(diffy/diffx)) + sign + offset
//with parenting
lookAt = "a";
L = thisComp.layer(lookAt);
p = L.toComp(L.anchorPoint);
d = thisLayer.toComp(anchorPoint) - p
d[0] = (d[0]==0)?1:d[0];
rotation + radians_to_degrees(Math.atan(d[1]/d[0])) - 90*d[0]/ Math.abs(d[0])

Pixilation (slow footage)

numImages = 15;
fps = 1/thisComp.frameDuration;
framesToWait = 3;Math.floor(time*fps/framesToWait%numImages)/fps;

Text scroller (DOS!)

//remplacer par les chiffres si il y a pas les sliders control
charlen =Math.abs(Math. round(effect("taille ligne")("Slider"),0)); //20
numlines = Math.abs(Math. round(effect("nbre lignes")("Slider"),0)); //5
step = Math.abs(Math. round(effect("avancement")("Slider"),0)); //timeToFrames(t = time + thisComp.displayStartTime, 1.0 / thisComp.frameDuration, isDuration = false);

txt = text.sourceText;
splitxt = txt.split("\r");
output = "";
for(i=0;i<numlines;i++){
	output += (i+step > numlines)?".\r":splitxt[i+step].substring(0,charlen)+"\r";
}
output;
//single line
src = text.sourceText;
len = src.length;
scroll = time*25;
src.slice(scroll%len)+src.slice(0,scroll%len)

/////////////


charlen =200; numlines = 15; step = time/thisComp.frameDuration; txt = text.sourceText; splitxt = txt.split("\r"); output = ""; for(i=step;i<(step+numlines);i++){ output += (splitxt.length<=i)?"\r":splitxt[i-1].substring(0,charlen)+"\r"; } output; </pre>

Open two simultaneous After Effects

"C:\Program Files\Adobe\Adobe After Effects CS5\Support Files\AfterFX.exe" -m


Command-Line

@echo off
"C:\Program Files\Adobe\Adobe After Effects CS5\Support Files\aerender.exe" -mp -project "W:\