-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointAlongXAxis.jsx
72 lines (64 loc) · 2.6 KB
/
pointAlongXAxis.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var comp = app.project.activeItem;
var t = comp.time;
var size = [15,15];
function point(comp,size){
var ellipseShape = comp.layers.addShape();
var ellipse = ellipseShape.content.addProperty("ADBE Vector Shape - Ellipse");
ellipse.property("ADBE Vector Ellipse Size").setValue(size);
ellipseShape.content.addProperty("ADBE Vector Graphic - Fill");
return ellipseShape;
}
function xAnimate(point,t,pos){
point.position.setValueAtTime(t,[pos,540]);
}
function yAnimateRelToX(ypoint,xpoint){
ypoint.transform.position.expression = "\
var xPosition = thisComp.layer(\""+xpoint.name+"\").transform.position[0];\
var yPosition = (-100*(Math.round(10000*Math.cos(((xPosition-960)/100))))/10000) +540;\
[960,yPosition]";
}
function lineAnimateRelToX(xpoint){
var line = comp.layers.addShape();
line.name = "verticalLine";
var path = line.content.addProperty("ADBE Vector Shape - Group");
path.path.expression = "\
var xPosition = thisComp.layer(\""+xpoint.name+"\").transform.position[0]-960;\
var yPosition = (-100*(Math.round(10000*Math.cos(((xPosition)/100))))/10000);\
createPath(points =[[xPosition,0],[xPosition,yPosition]],\
inTangents = [], outTangents = [], is_closed = false)";
addStroke(line,5);
}
function lineAnimateRelToY(xpoint,ypoint){
var line = comp.layers.addShape();
line.name = "horizontalLine";
var path = line.content.addProperty("ADBE Vector Shape - Group");
path.path.expression = "\
var xPosition = thisComp.layer(\""+xpoint.name+"\").transform.position[0]-960;\
var yPosition = thisComp.layer(\""+ypoint.name+"\").transform.position[1]-540;\
createPath(points =[[0,yPosition],[xPosition,yPosition]],\
inTangents = [], outTangents = [], is_closed = false)";
addStroke(line,5);
}
function addStroke(shape,strokeWidthValue){
var stroke = shape.content.addProperty("ADBE Vector Graphic - Stroke");
var strokeWidth = stroke.property("ADBE Vector Stroke Width");
strokeWidth.setValue(strokeWidthValue);}
var xPoint = point(comp,size);
xPoint.name = "xPoint";
var yPoint = point(comp,size);
yPoint.name = "yPoint";
// animate x point
xAnimate(xPoint,0,0);
xAnimate(xPoint,8,1920);
//animate y point
yAnimateRelToX(yPoint,xPoint);
//animate connecting lines
lineAnimateRelToX(xPoint);
lineAnimateRelToY(xPoint,yPoint);
var functionPoint = point(comp,size);
functionPoint.name = "functionPoint";
functionPointExpression="\
var xPosition = thisComp.layer(\""+xPoint.name+"\").transform.position[0];\
var yPosition = thisComp.layer(\""+yPoint.name+"\").transform.position[1];\
[xPosition,yPosition]";
functionPoint.transform.position.expression=functionPointExpression;