parent
f5fa293804
commit
753c6ec682
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Base ScriptUI Panel v.0.1
|
||||
|
||||
by Jorge Vásquez Pérez
|
||||
|
||||
Changes 0.2:
|
||||
- None
|
||||
|
||||
*/
|
||||
|
||||
(function createNullsFromPaths (thisObj) {
|
||||
/* Build UI */
|
||||
function buildUI(thisObj) {
|
||||
|
||||
var windowTitle = "windowTitle";
|
||||
var firstButton = "firstButton";
|
||||
var secondButton = "secondButton";
|
||||
var thirdButton = "thirdButton";
|
||||
var win = (thisObj instanceof Panel)? thisObj : new Window('palette', windowTitle);
|
||||
win.spacing = 0;
|
||||
win.margins = 4;
|
||||
var myButtonGroup = win.add ("group");
|
||||
myButtonGroup.spacing = 4;
|
||||
myButtonGroup.margins = 0;
|
||||
myButtonGroup.orientation = "row";
|
||||
win.button1 = myButtonGroup.add ("button", undefined, firstButton);
|
||||
win.button2 = myButtonGroup.add ("button", undefined, secondButton);
|
||||
win.button3 = myButtonGroup.add ("button", undefined, thirdButton);
|
||||
myButtonGroup.alignment = "center";
|
||||
myButtonGroup.alignChildren = "center";
|
||||
|
||||
win.button1.onClick = function(){
|
||||
button1Click();
|
||||
}
|
||||
win.button2.onClick = function(){
|
||||
button2Click();
|
||||
}
|
||||
win.button3.onClick = function(){
|
||||
button3Click();
|
||||
}
|
||||
|
||||
win.layout.layout(true);
|
||||
|
||||
return win
|
||||
}
|
||||
|
||||
|
||||
// Show the Panel
|
||||
var w = buildUI(thisObj);
|
||||
if (w.toString() == "[object Panel]") {
|
||||
w;
|
||||
} else {
|
||||
w.show();
|
||||
}
|
||||
|
||||
|
||||
/* General functions */
|
||||
|
||||
/* Project Specific functions */
|
||||
function button1Click(){
|
||||
alert("Button 1 was clicked");
|
||||
}
|
||||
function button2Click(){
|
||||
alert("Button 2 was clicked");
|
||||
}
|
||||
function button3Click(){
|
||||
alert("Button 3 was clicked");
|
||||
}
|
||||
|
||||
|
||||
})(this);
|
||||
@ -0,0 +1,20 @@
|
||||
#include "y.jsx";
|
||||
my_comps = getSelectedProjectItems();
|
||||
var my_comp = getSelectedProjectItems()[0];
|
||||
|
||||
// new_size = [ 240,320 ];
|
||||
//new_size = [ 4096, 2048 ];
|
||||
|
||||
|
||||
|
||||
//setFPS( my_comp, 24 );
|
||||
|
||||
for ( var i = 0 ; i < my_comps.length ; i++ ){
|
||||
var my_comp = my_comps[i];
|
||||
setFPS( my_comp, 24 );
|
||||
}
|
||||
|
||||
//selectLayersByParented( false );
|
||||
|
||||
//resizeCompCanvasCentered( my_comp, new_size, true )
|
||||
//alert(system.callSystem("whoami"))
|
||||
@ -0,0 +1,83 @@
|
||||
|
||||
function getSelectedProjectItems(){
|
||||
var items = [];
|
||||
var p = app.project;
|
||||
for ( var i = 1 ; i <= p.numItems ; i ++ ){
|
||||
var item = p.item(i);
|
||||
if ( item.selected ){
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
function selectLayersByParented( isParented ){
|
||||
layersToSelect = getLayersByParented( isParented );
|
||||
for ( var i = 0; i < layersToSelect.length; i ++ ){
|
||||
layerToSelect = layersToSelect[i];
|
||||
layerToSelect.selected = true;
|
||||
}
|
||||
}
|
||||
function getLayersByParented( isParented ){
|
||||
var active_comp = app.project.activeItem;
|
||||
var filtered_layers = [];
|
||||
|
||||
for ( var i = 1; i <= active_comp.layers.length ; i ++ )
|
||||
{
|
||||
var my_layer = active_comp.layers[i];
|
||||
|
||||
if ( (my_layer.parent == null) != isParented )
|
||||
{
|
||||
filtered_layers.push( my_layer );
|
||||
};
|
||||
}
|
||||
|
||||
return filtered_layers
|
||||
}
|
||||
function centerLayer( my_layer , size ){
|
||||
my_layer.position[0] = size[0]/2;
|
||||
my_layer.position[1] = size[1]/2;
|
||||
alert(my_layer.position);
|
||||
}
|
||||
function resizeCompCanvas( comp, new_size ){
|
||||
comp.width = new_size[0];
|
||||
comp.height = new_size[1];
|
||||
};
|
||||
function setFPS( comp, newFPS ){
|
||||
comp.frameDuration = 1/newFPS;
|
||||
};
|
||||
function setDuration( myComp, newSecondsDuration ){
|
||||
|
||||
};
|
||||
function setDurationInFrames( myComp, newFrameDuration ){
|
||||
//myComp.
|
||||
};
|
||||
function resizeCompCanvasCentered( my_comp, new_size, keep_scaler ){
|
||||
app.beginUndoGroup("Resize Comp Canvas Centered")
|
||||
var n = my_comp.layers.addNull();
|
||||
|
||||
//center null on actual comp size
|
||||
n.position.setValue([my_comp.width/2,my_comp.height/2]);
|
||||
resizeCompCanvas( my_comp , new_size );
|
||||
|
||||
//parent unparented layers to MAIN_SCALER
|
||||
var unparenterLayers = getLayersByParented( false );
|
||||
for ( var i = 0; i < unparenterLayers.length ; i ++ ){
|
||||
var current_layer = unparenterLayers[i];
|
||||
|
||||
if ( (current_layer != n) && ( true )) {
|
||||
current_layer.parent = n;
|
||||
}
|
||||
}
|
||||
|
||||
// center null to new comp size
|
||||
n.position.setValue(new_size/2);
|
||||
|
||||
//get rid of scaling null or not.
|
||||
if (keep_scaler)
|
||||
{
|
||||
n.name = 'MAIN_SCALER';
|
||||
}else{
|
||||
n.remove()
|
||||
}
|
||||
app.endUndoGroup();
|
||||
}
|
||||
Loading…
Reference in new issue