// Declarationvar myVariable;var 🍎,🍐,🍐// Initializationvar fruit = 🍎;var fruitArray = [🍏,🍎,🍐,🍊,🍋,🍌,🍉,🍇];String"string is text"// For-Loopsfor( var i = 0; i < value ; i++){statement}//if/else statementsif (fruit){statement} else {statement}// Shorthand if statementif(x==1) 10;// Using ternary operationcondition ? exprIfTrue : exprIfFalse//Objectvar x = {firstName:"John", lastName:"Doe"}; //// Regular Expressions (Regex)"\n"// Single line comment/* Multi-line commentEtiam aliquet et mi quis tempor.Nulla ullamcorper, sapien in molestie rhoncus,justo magna molestie dolor,Nullam dignissim interdum mi sit a */
velocity = v or velmultiplier = mul;position = pos, myPosdistance = dstsourceRect = smyLayermyNumLayerstarget = tgt
Declare variable before loop statements
time*50;// for adding to an alement in an array such as position:value + [time*50,0]// for value change to start at inPoint(time-inPoint)*50// Throw (move at a constant speed without keyframes)veloc = -10; //horizontal velocity (pixels per second)x = position[0] + (time - inPoint) *veloc;y = position[1];[x,y]
var dst = 50;var x= thisComp.layer(index-1).transform.position[0]+dst ;value + [x,0] ;
var xy = 0;var dst = 50;var x= thisComp.layer(index-1).transform.position[0]+dst ;var x= thisComp.layer(index-1).transform.position[0]+dstxy==0? value+[x,0]: value+[0,y]; // Ternary conditional operator
//Top lefts=sourceRectAtTime();[0,0];// or [s.left,s.top] or [s.left,0]// Return original positions=sourceRectAtTime(); value-[s.width/2,s.height/2];// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑s=sourceRectAtTime();[0,s.top+s.height/2]+value// Top rights=sourceRectAtTime();[s.width,s.top];// ← ← ← ← ←s=sourceRectAtTime();[s.left,0]// or [[s.left,s.height/2]// Centers=sourceRectAtTime();[s.left+s.width/2,s.top+s.height/2]+value// → → → → →s=sourceRectAtTime();[s.width,s.height/2]// Bot lefts=sourceRectAtTime();[s.left,s.height];// ↓ ↓ ↓ ↓ ↓s=sourceRectAtTime();[s.width/2,s.height];//Bot rights=sourceRectAtTime();[s.width,s.height];
seed = 20;min = [25,25,-1900]; // Connect to 3D Point Control for controlmax = [thisComp.width,thisComp.height,50]seedRandom(seed,true);random(min,max);// This is same as this// x= random(min[0],max[0]);// y= random(min[1],max[1]);// z= random(min[2],max[2]);//[x,y,z]
s = [];ps = parent.transform.scale.value;for (i = 0; i < ps.length; i++){s[i] = value[i]*100/ps[i];}s
arr = value;ps = parent.transform.scale.value;ratio = 100/ ps[0];arr*ratio;
target = thisComp.layer("Null 1"); // set this to the layer to aim atp = position - target.position;radiansToDegrees( Math.atan2( p[1], p[0] ) )- 90
target = thisComp.layer("controls"); // set this to the layer to aim atp = thisLayer.toWorld(anchorPoint) - target.position;radiansToDegrees(Math.atan2(p[1], p[0])) - 90
target = thisComp.layer("Null 1");// set this to the layer to aim atlookAt( position, target.position )
L = thisComp.layer("Null 1");v = L.toWorldVec([1,0]);radiansToDegrees(Math.atan2(v[1],v[0]))
try{cornerEase = 3;p = transform.position;t = Math.min(Math.max(time,p.key(1).time+.001),p.key(p.numKeys).time);pre = position.valueAtTime(t-thisComp.frameDuration*cornerEase);post = position.valueAtTime(t+thisComp.frameDuration*cornerEase);delta = post-pre;orient = radiansToDegrees(Math.atan2(delta[0],-delta[1]));value+orient+180}catch(err){value}
value – parent.transform.rotation
// VARIABLESminSeg = 1.5; //minimum interval (must be > 0)maxSeg = 2.5; //maximum interval (must be > minSeg)// flickering durationminFlicker = .5; //must be less than minSegmaxFlicker = 1; // must be less than minSegflickerDur = random(minFlicker,maxFlicker);//initial conditionssegEndTime = 0;i = 1;// Continuous loop: create a fixed random segment value and add to segEndTimewhile (time >= segEndTime){i += 1;seedRandom(i,true);segEndTime = segEndTime + random(minSeg,maxSeg);}// Switch back to use the current time as input to the random seed.seedRandom(1,false);// As time > threshold, flickerif (time > segEndTime - flickerDur){random(0,100) }else{ 100 }// Source: http://www.motionscript.com/expressions-lab-ae65/swinging-light.html// Also see: http://www.motionscript.com/mastering-expressions/random-3.html
// control = thisComp.layer("control"); // connect to null layer with slidersfreq = 1;amp = 100;octave = 1;amp_mult = 3;wiggle(freq, amp, octave, amp_mult, time)
// control = thisComp.layer("control"); // connect to null layer with slidersfreq = 1;amp = 100;octave = 1;amp_mult = 3;opacity = wiggle(freq, amp, octave, amp_mult, time)// VARIABLESminSeg = control.effect("minSeg")("Slider"); //minimum interval (must be > 0)maxSeg = control.effect("maxSeg")("Slider");; //maximum interval (must be > minSeg)// flickering durationminFlicker = control.effect("minFlicker")("Slider");; //must be less than minSegmaxFlicker = control.effect("maxFlicker")("Slider");; // must be less than minSegflickerDur = random(minFlicker, maxFlicker);//initial conditionssegStartTime = 0;segEndTime = 0;i = 1;// Continuous loop: create a fixed random segment value and add to segEndTimewhile (time >= segEndTime) {i += 1;seedRandom(i, true);segStartTime = segEndTime;segEndTime = segEndTime + random(minSeg, maxSeg);}// Switch back to use the current time as input to the random seed.seedRandom(1, false);// As time moves threshold, flickerif (time > segEndTime - flickerDur) {random(0, 100)} else {opacity}
// Mass flickeringvel = 50;seedRandom(0,true);Math.sin(time*vel+random(index))*100;
// 'Wave flickering'vel = 50;seedRandom(0,true);Math.sin(time*vel+index)*100;// Combiningbool = 1 ;vel = 50;seedRandom(0,true);wave=Math.sin(time*vel+index)*100;rand =Math.sin(time*vel+random(index))*100;bool==0 ? wave : rand;
seed = 29;threshold = linear(time,0,thisComp.duration,0,100); // or Connect to slider to animate switch on & offseedRandom(seed,true);randValue = random(0,90);if(randValue < threshold){100;} else 0
seed = 29;seedRandom(seed,true);delay = random(0,1);t = framesToTime(20) // or usethisComp.durationlinear(time, 0+delay,t+delay,0,100)
//VARIABLESfadeDuration = 1;maxDelay = .5//SETUPseedRandom(index,true);delay = random(maxDelay);t = time -(inPoint + delay);// EXECUTIONlinear(t,0,fadeDuration,0,100);
// Distance Based Opacity Fade// Original: https://helpx.adobe.com/after-effects/using/expression-examples.html// Full Tutorial: https://www.youtube.com/watch?v=I-Acdl_l9G0&t=14sstartFade = 500;endFade = 3000;try {C = thisComp.activeCamera.toWorld([0,0,0]);} catch(err) {w = thisComp.width * thisComp.pixelAspect;z = (w / 2)/Math.tan(degreesToRadians(19.799));C = [0,0,-z];}P = toWorld(anchorPoint);d = length(C, P);linear(d, startFade, endFade, 100, 0)
if (toCompVec([0, 0, 1])[2] > 0 ) value else 0
txt = thisComp.layer("Text").text.sourceText;c = parseInt(txt,16);r = c >> 16;g = (c & 0x00ff00) >> 8;b = c & 0xff;[r,g,b,255]/255
// Apply on fillseedRandom(index,true); // change true to 0 for constant changerandom([0,0,0,1],[1,1,1,1])
f = 2; // number of frames before and after to averagev = [0,0];for (i = -f; i <= f; i++){v += position.velocityAtTime(i*thisComp.frameDuration + time);}v /= (f*2+1);a = Math.atan2(v[1],v[0]);radiansToDegrees(a)// turn off auto-orient
//y-rotation for 3d layersf = 2; // number of frames before and after to averagev = [0, 0, 0];for (i = -f; i <= f; i++) {v += position.velocityAtTime(i * thisComp.frameDuration + time);}v /= (f * 2 + 1);a = Math.atan2(v[0], v[2]);radiansToDegrees(a)
// frequency by amplitude = how fast by how muchwiggle(20,30);[value[0], wiggle(20,30)[1]] // wiggle y-axis only// Smooth wiggle — freq,amp,octave,amp_multwiggle(20,30,1,2,time)// Jumpy Wiggle 1 (moves at a random FPS) Makes wiggle skip and hold rather than move fluidly.v=wiggle(5,50);if(v < 50)v=0;if(v > 50)v=100;v;// Jumpy Wiggle 2 (moves at a defined FPS)fps=5; //frequencyamount=50; //amplitudewiggle(fps,amount,octaves = 1, amp_mult = 0.5,(Math.round(time*fps))/fps);
// Inertial Bounce (moves settle into place after bouncing around a little)// // Source: https://forums.creativecow.net/docs/forums/post.php?forumid=227&postid=19145&univpostid=19145&pview=tamp = .05;freq = 4.0;decay = 2.0; // springynessn = 0;if (numKeys > 0){n = nearestKey(time).index;if (key(n).time > time){n--;}}if (n == 0){t = 0;}else{t = time - key(n).time;}if (n > 0){v = velocityAtTime(key(n).time - thisComp.frameDuration/10);value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);}else{value;}
WIP---choice = Math.floor(random(0,2));seedRandom(0,false);stepx = random(0,50);stepy = random(0,20);if(choice ==0){value + [stepx,0];} else if( choice ==1){value +[0,stepy];}
// source: Dan Ebbertcenter = [thisComp.width,thisComp.height]/2;radius = 200;period = 3;angle = 2*Math.PI*time/period;x = 2*radius*Math.cos(angle)*Math.sqrt(Math.cos(angle)*Math.cos(angle));y = 2*radius*Math.cos(angle)*Math.sin(angle);center + [x,y]
u = 1v = 2a = 540;x = a*Math.cos(v*time)*Math.sin(u*time);y = a*Math.cos(v*time)*Math.cos(u*time);[x,y]+[thisComp.width/2,thisComp.height/2]
u = 1v = 10;a = 75 // inner radiusc = 450 // outer radiusphase = 10; // animate thisx = (c+a*Math.cos(v*phase))*Math.cos(u*phase);y = (c+a*Math.cos(v*phase))*Math.sin(u*phase);[x,y]+[thisComp.width/2,thisComp.height/2]
freq = 60;mul = 500;radius = 90;x = radius*Math.sin(time*freq)y = radius*Math.cos(time*freq)z = time*mulvalue + [x,y,z]
//Create a null layer at the top named "Start Tiles" with a Slider effect "Columns",//and one at the bottom named "End Tiles"// For Position:var controlLayer = thisComp.layer("Start Tiles");var numColumns = Math.floor(thisComp.layer("Start Tiles").effect("Columns")("Slider").value);var tileIndex = index - controlLayer.index-1;var columnIndex = tileIndex%numColumns;var rowIndex = Math.floor(tileIndex/numColumns);var columnWidth = thisComp.width/numColumns;var firstTile = thisComp.layer(controlLayer.index+1);var rowHeight = firstTile.height/firstTile.width*columnWidth;var xPos = columnWidth*(columnIndex+.5);var yPos = rowHeight*(rowIndex+.5); [xPos, yPos];// For Scale:var controlLayer = thisComp.layer("Start Tiles");var numColumns = Math.floor(thisComp.layer("Start Tiles").effect("Columns")("Slider").value);var columnWidth = thisComp.width/numColumns;var firstTile = thisComp.layer(controlLayer.index+1);var rowHeight = firstTile.width/firstTile.height*columnWidth;var xyScale = columnWidth/width*100; [xyScale, xyScale]
// POSITION Setupvar controlLayer = thisComp.layer("Start Tile");var numColumns = Math.floor(thisComp.layer("Start Tile").effect("Columns")("Slider").value); var Mmargins = Math.floor(thisComp.layer("Start Tile").effect("Margins")("Slider").value); var myWidthRatio = thisComp.layer("Start Tile").effect("Height Adjustment")("Slider"); var myZPos = thisComp.layer("Start Tile").effect("Z-Pos Adjustment")("Slider"); var mySeed = thisComp.layer("Start Tile").effect("Seed")("Slider"); // Indexing var tileIndex = index - controlLayer.index-1; var columnIndex = tileIndex%numColumns; var rowIndex = Math.floor(tileIndex/numColumns); if (rowIndex % 2 == 0) {var oddEven = 1;}else{oddEven=0;} // Z-Positioning seedRandom(index+mySeed, true); var zPos = random(-myZPos,myZPos);// Positioningvar columnWidth = thisComp.width/numColumns ;var firstTile = thisComp.layer(controlLayer.index+1);var rowHeight = firstTile.height/firstTile.width*columnWidth;var xPos = columnWidth*(columnIndex+.5);var yPos = rowHeight*(rowIndex+.5);[xPos +oddEven*columnWidth/2, yPos*myWidthRatio,zPos];//// SCALE Setupvar controlLayer = thisComp.layer("Start Tile");var numColumns = Math.floor(thisComp.layer("Start Tile").effect("Columns")("Slider").value);var myScaleRatio = thisComp.layer("Start Tile").effect("Scale Adjustment")("Slider");// Indexingvar columnWidth = thisComp.width/numColumns ;var firstTile = thisComp.layer(controlLayer.index+1);var rowHeight = firstTile.width/firstTile.height*columnWidth;//Scalingvar xyScale = columnWidth/width*100;[xyScale, xyScale]*myScaleRatio;
// Create two text layers named "DATA1" & "DATA2"// Variablespad = 50;xPad = 15;yPad = 15;seed = 1 // allow you to change between two text layers// Making it workif(seed==1){src = thisComp.layer("DATA1")}else {src = thisComp.layer("DATA2")};box = src.sourceRectAtTime(time-src.inPoint);[box.width + pad + xPad, box.height+pad +yPad];
v = transform.position[0] // xd = length(v,thisComp.width/2);maxDist= 960;ease(d,0,maxDist,100,0)
/* There needs to be two layers named 'startCard' & 'endCard'This allows rotation value to dynamically change when layers are inserted or removed.All duplicates need to be placed within these two layers*///anchor pointradius = 500value+[0,0,radius]// Y rotationstartIndex=thisComp.layer("startCard").index;endIndex = thisComp.layer("endCard").index;numpt = startIndex-endIndex+1; // total number of layersmyIndex = index-startIndex;angle = 360/numptmyIndex*angle+
// Make sure there is a camera//OpacitystartVal = 0;endVal = 100;fadeAngle = 180;v = toCompVec([0,0,1]); // layer position to comp position in Zd = length(toWorld(anchorPoint),thisComp.layer("Camera 1").toWorld([0,0,0]));c = v[2]/d;ease(c,Math.cos(degreesToRadians(fadeAngle)),1.0,startVal,endVal)
angle = transform.yRotation%360;minAngle = 0;maxAngle = 360;mid = (maxAngle+minAngle)/2;if (angle < mid)linear(angle,minAngle,mid,100,0)elselinear(angle,mid,maxAngle,0,100)
// Source Dan Ebbertfr = 12; // frame rate;numFrames = 8;seedRandom(index,true);seg = Math.floor(time*fr);f = Math.floor(random(numFrames));for (i = 0; i < seg; i++)f = (f + Math.floor(random(1,numFrames)))%numFrames;framesToTime(f);
seedRandom(index,true);myDelay = random(1,10);time + myDelay;
fps = 1;x = framesToTime(Math.round(time*fps))//There probably is a better way but I cannot figured it out right now.
//Apply this to a composition with a image sequence insideseedRandom(0,true);t= random(0,72);framesToTime(t);
n = 3 // framestime*n
n = 3; // play every __ framesm = 3; // hold each frame ___ timesf= timeToFrames(timeRemap);p=Math.floor(f/m);framesToTime(p*n);
Create a preComp with all the different types of animation
In the main Comp, put an expression on the time remapping of that preComp
Add markers to trigger animations
Learn more
//https://gist.github.com/animoplex/cecf1c64aec4f2733ecd0edbebf4786d
// Copying animation of a layer, and start it at inPoint of layerthisComp.layer(index+1).transform.position.valueAtTime(time-inPoint)// Using delayoffset = 1;thisComp.layer(index+1).transform.position.valueAtTime(time-offset)
// VARIABLES + SETUPtarget = thisComp.layer("master").transform.scale;maxDist = 1000;maxDelay = 1;dst = length(transform.position,[thisComp.width/2,thisComp.height/2]);delay = linear(dst,0,maxDist,0,maxDelay);// EXECUTIONtarget.valueAtTime(time-delay)
//apply to scaletarget = thisComp.layer("fade");fade = target.effect("scale")(1);delay = target.effect("delay")(1)*thisComp.frameDuration;dist = length(thisLayer.toWorld(thisLayer.anchorPoint), target.toWorld(target.anchorPoint));seed = seedRandom(15, true)randomRange = target.effect("random")("Slider");rand = (random(-randomRange, randomRange))*thisComp.frameDuration;offset = delay/dist;s = fade.valueAtTime(time - offset - rand);[s,s]
//Create a null named "EFFECTOR"//Add 2 Slider Control Effects renamed to "maxDist" and "delay"// EXECUTEtarget = thisComp.layer("EFFECTOR").transformmaxDist = thisComp.layer("EFFECTOR").effect("maxDist")("Slider");maxDelay = thisComp.layer("EFFECTOR").effect("delay")("Slider");dst = length(transform.position, target.position);delay = linear(dst, 0, maxDist, 0, maxDelay);// EXECUTIONtarget.opacity.valueAtTime(time - delay)