Skip to content

Commit 7ce377d

Browse files
committed
update types
1 parent 866cb77 commit 7ce377d

4 files changed

Lines changed: 16 additions & 22 deletions

File tree

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ For a legacy version that works in the ExtendScript engine, view the [Extendscri
3939
2. **Create a reference to the library in an expression:**
4040

4141
```javascript
42-
const funcLib = footage('aefunctions.jsx').sourceData.getFunctions(time);
42+
const funcLib = footage('aefunctions.jsx').sourceData.getFunctions();
4343
```
4444

4545
(You can name the library variable whatever you'd like).
4646

47-
`getFunctions` does some initial setup, and then returns an object containing the functions.
48-
49-
> Passing the `time` value to `getFunctions` avoids passing it to each function that accesses the comp time.
50-
5147
3. **Access the functions in your expression:**
5248

5349
```javascript
@@ -63,7 +59,7 @@ For a legacy version that works in the ExtendScript engine, view the [Extendscri
6359
An example expression that uses the library is:
6460

6561
```javascript
66-
const ae = footage('aefunctions.jsx').sourceData.getFunctions(time);
62+
const ae = footage('aefunctions.jsx').sourceData.getFunctions();
6763
ae.attachKeys(2, 2);
6864
```
6965

@@ -72,7 +68,7 @@ You can also [destructure](https://developer.mozilla.org/en-US/docs/Web/JavaScri
7268
```javascript
7369
const { attachKeys, countLines } = footage(
7470
'aefunctions.jsx'
75-
).sourceData.getFunctions(time);
71+
).sourceData.getFunctions();
7672
```
7773

7874
[Back To Top ↑]

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aefunctions",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "Speed up your After Effects expression writing with a library of useful functions",
55
"main": "dist/aefunctions.jsx",
66
"scripts": {
@@ -30,6 +30,6 @@
3030
"typescript": "^3.9.7"
3131
},
3232
"dependencies": {
33-
"expression-globals-typescript": "^2.1.1"
33+
"expression-globals-typescript": "^3.0.0"
3434
}
3535
}

src/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import {
22
PathProperty,
33
Layer,
44
Comp,
5-
add,
65
Vector,
7-
mul,
86
Points,
97
Vector2D,
108
PathValue,
@@ -14,7 +12,7 @@ const thisProperty = new PathProperty<PathValue>([[0, 0]]);
1412
const thisLayer = new Layer();
1513
const thisComp = new Comp();
1614

17-
function getFunctions(time: number) {
15+
function getFunctions(time: number = thisLayer.time) {
1816
function attachKeys(inKeys: number = 2, outKeys: number = 2) {
1917
if (inKeys >= 1 && outKeys >= 1) {
2018
// There is in and out animation
@@ -102,9 +100,9 @@ function getFunctions(time: number) {
102100
let velocity = thisProperty.velocityAtTime(
103101
thisProperty.key(curKey).time - thisComp.frameDuration / 10
104102
) as Vector;
105-
return add(
103+
return thisLayer.add(
106104
thisProperty.value as Vector,
107-
mul(
105+
thisLayer.mul(
108106
velocity,
109107
(amp * Math.sin(freq * t * 2 * Math.PI)) / Math.exp(decay * t)
110108
)
@@ -135,10 +133,10 @@ function getFunctions(time: number) {
135133
columnWidth * (columnNum - 1),
136134
rowHeight * (rowNum - 1),
137135
];
138-
const topRight: Vector = add(topLeft, [columnWidth, 0]);
136+
const topRight: Vector = thisLayer.add(topLeft, [columnWidth, 0]);
139137

140-
const bottomLeft: Vector = add(topLeft, [0, rowHeight]);
141-
const bottomRight: Vector = add(topRight, [0, rowHeight]);
138+
const bottomLeft: Vector = thisLayer.add(topLeft, [0, rowHeight]);
139+
const bottomRight: Vector = thisLayer.add(topRight, [0, rowHeight]);
142140

143141
return [topLeft, topRight, bottomRight, bottomLeft];
144142
}
@@ -160,7 +158,7 @@ function getFunctions(time: number) {
160158
const x = xGrid * 1.75 - yGrid;
161159
const y = xGrid + yGrid / 1.75;
162160

163-
return add(offset, [x, y]);
161+
return thisLayer.add(offset, [x, y]);
164162
}
165163

166164
function getLayerBoundsPath(

0 commit comments

Comments
 (0)