forked from ae-scripting/scripting-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeClosest16.jsx
50 lines (37 loc) · 1.2 KB
/
makeClosest16.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
//small script for making comp size divisible by 16
//simple GUI
//Nik Ska, 2013
//CC-SA-BY
var make16 = this;
make16.buildGUI = function(thisObj){
thisObj.w = (thisObj instanceof Panel) ? thisObj : new Window("palette", "16", undefined, {resizeable:true});
thisObj.w.alignChildren = ['left', 'top']
//thisObj.w.size = [50,50];
thisObj.w.minimumSize = "width: 50, height: 50";
//thisObj.w.maximumSize = "width:50, height: 50";
var makeit = thisObj.w.add("button", undefined, "16!");
makeit.size = [30,30];
makeit.onClick = function(){
thisObj.run();
}
if (thisObj.w instanceof Window){
thisObj.w.center();
thisObj.w.show();
}
else thisObj.w.layout.layout(true);
}
make16.run = function(){
var activeComp = app.project.activeItem;
var getClosest16 = function(a){
if(a%16 == 0) return a;
else return 16*(Math.floor(a/16)+1);
}
if(activeComp != null && activeComp instanceof CompItem){
var compSize = [activeComp.width, activeComp.height];
app.beginUndoGroup("Resize to closest 16");
activeComp.width = getClosest16(compSize[0]);
activeComp.height = getClosest16(compSize[1]);
app.endUndoGroup();
}
}
make16.buildGUI(make16)