Skip to content

Instantly share code, notes, and snippets.

@AEnMe
AEnMe / TrimPath-OffsetStroke .js
Last active July 1, 2020 07:51
TrimPath-OffsetStroke
//Used to offset the dashes of a stroke while the trim start is animated.
start = thisProperty.propertyGroup(4).content("Trim Paths 1").start; // Path to the Trim Path's start slider
path = thisProperty.propertyGroup(4).content("Path 1").path; // Path to the vector path
n = 0;
for (i = 0; i < path.points().length - 1; i++) {
n += length(path.points()[i], path.points()[i + 1]); // Sum of all the length between two points
}
offset = start * n / 100; // offset the dashes to stay in place while start is animated
value + offset;
@AEnMe
AEnMe / Circle - tangent pin.jsx
Last active July 28, 2020 07:43
Drawing conic tangents on ellipse
poz = content("Group 1").transform.position; // Cicrle Position
centre= [0,0]; // PIVOT POINT
cx = poz[0];
cy = poz[1];
diametre = content("Group 1").content("Ellipse Path 1").size;
r = diametre[1] / 2;
P = length( centre , [Math.abs(cx), Math.abs(cy)]);
// ZEROED //
if ( P < r) {
@AEnMe
AEnMe / arrayMethod.jsx
Last active July 1, 2020 15:32
Array Method
var array = [1,3,4,2];
// Output an array as a string separated with the argument's contents.
array.join(", ")
//1, 3, 4, 2
// Outputs a string with elements separated by commas.
array.toString()
//1,3,4,2
// Sort an array alphabetically or numerically.
@AEnMe
AEnMe / stringMethod.jsx
Last active July 2, 2020 15:26
stringMethod
myString = "abcdef";
// Outputs 2 characters, starting after the first character.
myString.substr(1, 2)
//"bc"
// Outputs everything after the first character, through the second character.
myString.substring(1)
//"bcdef
// Converts the string to all uppercase letters.
@AEnMe
AEnMe / oscillate.jsx
Created July 1, 2020 15:49
oscillate
/*
name convention:
[1,2,3,4]
["sin","cos","square","saw","tri"]
or
["sine","cosine","square",sawtooth","triangle"]
*/
function oscillate(w,f,a,t) {
@AEnMe
AEnMe / TrimPath-RectangleSide.jsx
Created July 2, 2020 08:01
Trim one side of a rectangle
/*
Rename the Trim Path to the following:
left,l,LEFT,L
right,r,RIGHT,R
top,t,TOP,T
bottom,b,BOTTOM,B
*/
// TO PLACE ON TRIM.END
Rectangle = thisProperty.propertyGroup(3).content("Rectangle Path 1").size;
@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];
}
@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 / 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 / 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++) {