forked from MysteryPancake/After-Effects-Fun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspiralPath.js
More file actions
23 lines (20 loc) · 769 Bytes
/
spiralPath.js
File metadata and controls
23 lines (20 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Generates a spiral path, can be archimedes or fake logarithmic
// Based on pastebin.com/Y2YWSusr, adjusted for GhostGeemo on /r/AfterEffects Discord
// Connect to sliders
let spiralWidth = 1000;
let points = 200;
let steps = 20;
let vertices = [];
let scaleFactor = 8; // 1 = archimedes spiral, above = more logarithmic
// Main
let angle = 0;
const step = (Math.PI * 2) / steps;
const r = spiralWidth * 0.5;
for (let i = 0; i < points; i++) {
angle += step;
const radius = Math.pow(i / points, scaleFactor) * r; // Actual log spirals are theta^a, not a^theta
const x = Math.cos(angle) * radius; // Math.sin for clockwise
const y = Math.sin(angle) * radius; // Math.cos for clockwise
vertices[i] = [x, y];
}
createPath(vertices, [], [], false);