Skip to content

Instantly share code, notes, and snippets.

const note = dv.current();
function checkEmpty(field) {
return field ? field : "";
}
let wounds = checkEmpty(note.wounds);
let maxWounds = checkEmpty(note.max_wounds);
let health = note.health ? `(${note.health})` : "(-)";
let maxHealth = note.max_health ? `(${note.max_health})` : "(-)";
@AEnMe
AEnMe / Smarter dashes.js
Created October 14, 2020 10:24
Dashes counter offset on trim path start animation
anim = value + time * -30; // regular offset animation
st = thisProperty.propertyGroup(4).content("Trim Paths 1").start/100; // Trim Path animation
p = thisProperty.propertyGroup(4).content("Path 1").path.points(); // Vector Path (no tangent)
n=0;
for(i=0;i<p.length-1;i++){
n += length( p[i],p[i+1]);
}
smartStart = n*st;
n = 0;
if (numKeys > 0) {
n = nearestKey(time).index;
if (key(n).time > time) {
n--;
}
}
if (n == 0) {
time - inPoint;
} else {
@AEnMe
AEnMe / comp loop.jsx
Created July 14, 2020 10:14
Makes a compostion loop based on its duration
t = -inPoint + time; //to start at 0
d = comp(name).duration;
n = Math.round( t % d*100 )/100; //get rid of the floating
( n == d ) ? 0 : n;
@AEnMe
AEnMe / AnimationMarkerSwitch.jsx
Last active July 8, 2020 07:52
Animation redo every marker
n = 0;
if (marker.numKeys > 0) {
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) {
n--;
}
}
if (n == 0) {
value;
} else {
@AEnMe
AEnMe / rectangle corrected dashes.jsx
Created July 3, 2020 15:04
Apply this tothe dash of a stroke in th same group as the rectangle
rec = thisProperty.propertyGroup(4).content("Rectangle Path 1");
corner = rec.roundness;
x = rec.size[0];
y = rec.size[1];
myGaps = thisProperty.propertyGroup(1).gap;
diametre = Math.min(corner, Math.min(Math.max(0, x), y) / 2) * 2; // get the corrected curvature
perimetre = (x + y - diametre * 2) * 2 + diametre * Math.PI;
perimetre / Math.round(value) - myGaps;
@AEnMe
AEnMe / binary.jsx
Created July 3, 2020 14:02
To create binary text
nCharac = 5; // How many characters / line
lines = 3; // How many lines
dur = 10; // frames holding
seed = 0;
r = "";
i = seed + index;
seedRandom((dur == 0) ? i : i + Math.floor(time / dur / thisComp.frameDuration), 1);
for (j = 0; j < lines; j++) {
for (i = 0; i < nCharac; i++) {
@AEnMe
AEnMe / loopingPerlinNoise.jsx
Created July 2, 2020 15:43
Perlin Noise looped
//based on https://workbench.tv/tutorials/2019-05-10_LoopingNoise
amplitude = 100;
freq = .5; // loop/second
ofst = 0 ; //offset from 0 to 1
sed = 0; // seed
s = .1 ; // complexity
a = (time + ofst/freq ) * 2 * Math.PI * freq ;
x = Math.cos(a) * s + sed;
@AEnMe
AEnMe / unParent.jsx
Last active September 24, 2020 14:44
Stabilize the scale through parentings
/* To keep the same scale */
L=thisLayer;
s=transform.scale.value;
while(L.hasParent){
L=L.parent;
for(i=0;i<s.length;i++) // Apply it on the array
s[i] *= 100/L.scale.value[i];
}
s
@AEnMe
AEnMe / CirclePath.jsx
Created July 2, 2020 12:57
Create a circle with expression
r = effect("radius")(1);
vertex=[];
iTang=[];
oTang=[];
for(i=0;i<4;i++){
j= i+2;
vertex[i]= [ Math.cos(Math.PI/2 * (j+1) ) , Math.cos(Math.PI/2 * j ) ] * r;
iTang[i]=[ Math.cos(Math.PI/2 * j ) , Math.cos(Math.PI/2 * (j-1) ) ] * r * .5523 ;
oTang[i]= -iTang[i];
}