From 7ce377d11e2c32e3c8a07b7187c295b00d34f941 Mon Sep 17 00:00:00 2001 From: Tim Haywood Date: Sat, 26 Sep 2020 09:12:28 +1000 Subject: [PATCH] update types --- README.md | 10 +++------- package-lock.json | 8 ++++---- package.json | 4 ++-- src/index.ts | 16 +++++++--------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 51fdef4..955ec4b 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,11 @@ For a legacy version that works in the ExtendScript engine, view the [Extendscri 2. **Create a reference to the library in an expression:** ```javascript - const funcLib = footage('aefunctions.jsx').sourceData.getFunctions(time); + const funcLib = footage('aefunctions.jsx').sourceData.getFunctions(); ``` (You can name the library variable whatever you'd like). - `getFunctions` does some initial setup, and then returns an object containing the functions. - - > Passing the `time` value to `getFunctions` avoids passing it to each function that accesses the comp time. - 3. **Access the functions in your expression:** ```javascript @@ -63,7 +59,7 @@ For a legacy version that works in the ExtendScript engine, view the [Extendscri An example expression that uses the library is: ```javascript -const ae = footage('aefunctions.jsx').sourceData.getFunctions(time); +const ae = footage('aefunctions.jsx').sourceData.getFunctions(); ae.attachKeys(2, 2); ``` @@ -72,7 +68,7 @@ You can also [destructure](https://developer.mozilla.org/en-US/docs/Web/JavaScri ```javascript const { attachKeys, countLines } = footage( 'aefunctions.jsx' -).sourceData.getFunctions(time); +).sourceData.getFunctions(); ``` [Back To Top ↑] diff --git a/package-lock.json b/package-lock.json index 2d11d11..af63f6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "aefunctions", - "version": "1.4.0", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -48,9 +48,9 @@ "dev": true }, "expression-globals-typescript": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/expression-globals-typescript/-/expression-globals-typescript-2.1.1.tgz", - "integrity": "sha512-ZhekVUKUWHyJfpP/ftWcO3kUeYEogkwLCP1fucnyg3q0c2+vM1nPmaobSDEhW1tUBAHv7NYB5knQjgLI73WwPw==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/expression-globals-typescript/-/expression-globals-typescript-3.0.0.tgz", + "integrity": "sha512-BYJ6UDCXpyTJDqlRpcxrGXNcpCMIvWvRdIxIs7T+AE7fF3ksxNc99+GQaecDp+c03gKybyW9NkZ2JMAgGuUWsQ==" }, "fsevents": { "version": "2.1.3", diff --git a/package.json b/package.json index 1a178cd..42eb88e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aefunctions", - "version": "1.4.0", + "version": "1.5.0", "description": "Speed up your After Effects expression writing with a library of useful functions", "main": "dist/aefunctions.jsx", "scripts": { @@ -30,6 +30,6 @@ "typescript": "^3.9.7" }, "dependencies": { - "expression-globals-typescript": "^2.1.1" + "expression-globals-typescript": "^3.0.0" } } diff --git a/src/index.ts b/src/index.ts index 9db3ec8..07f3ab6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,9 +2,7 @@ import { PathProperty, Layer, Comp, - add, Vector, - mul, Points, Vector2D, PathValue, @@ -14,7 +12,7 @@ const thisProperty = new PathProperty([[0, 0]]); const thisLayer = new Layer(); const thisComp = new Comp(); -function getFunctions(time: number) { +function getFunctions(time: number = thisLayer.time) { function attachKeys(inKeys: number = 2, outKeys: number = 2) { if (inKeys >= 1 && outKeys >= 1) { // There is in and out animation @@ -102,9 +100,9 @@ function getFunctions(time: number) { let velocity = thisProperty.velocityAtTime( thisProperty.key(curKey).time - thisComp.frameDuration / 10 ) as Vector; - return add( + return thisLayer.add( thisProperty.value as Vector, - mul( + thisLayer.mul( velocity, (amp * Math.sin(freq * t * 2 * Math.PI)) / Math.exp(decay * t) ) @@ -135,10 +133,10 @@ function getFunctions(time: number) { columnWidth * (columnNum - 1), rowHeight * (rowNum - 1), ]; - const topRight: Vector = add(topLeft, [columnWidth, 0]); + const topRight: Vector = thisLayer.add(topLeft, [columnWidth, 0]); - const bottomLeft: Vector = add(topLeft, [0, rowHeight]); - const bottomRight: Vector = add(topRight, [0, rowHeight]); + const bottomLeft: Vector = thisLayer.add(topLeft, [0, rowHeight]); + const bottomRight: Vector = thisLayer.add(topRight, [0, rowHeight]); return [topLeft, topRight, bottomRight, bottomLeft]; } @@ -160,7 +158,7 @@ function getFunctions(time: number) { const x = xGrid * 1.75 - yGrid; const y = xGrid + yGrid / 1.75; - return add(offset, [x, y]); + return thisLayer.add(offset, [x, y]); } function getLayerBoundsPath(