Cambiando bind between 2, incomplete

renaissance
yorch 11 years ago
parent e07df6d9d4
commit 868c1cb141

@ -1,197 +1,110 @@
yEntreDeux_data = new Object(); #include "../yScripts/y_JSExtensions.jsx";
function YGenericTool()
yEntreDeux_data.scriptName = 'yBindBetween2'; {
yEntreDeux_data.scriptDesc = 'Constraints a layer between two others, position and rotation-wise'; this.info =
{
yEntreDeux_data.scriptVer = '0.12a'; name : "yBindBetween2",
yEntreDeux_data.webLink = 'yorchnet.com'; version : 0.13,
stage : "development",
//if yToolBox Exists add it to its tool list. description : "Constraints a layer between two others, position and rotation-wise",
if (typeof(YTB)!=='undefined'){ url : "yorchnet.com"
YTB.tools.push(yEntreDeux_data); };
this.appearence =
//it should be called from toolbox. {
/* yEntreDeux_data.buttonWidth=76; buttonHeight : 30,
yEntreDeux_data.buttonHeight=30; buttonWidth : 126
*/ };
yEntreDeux_data.btnLayout = "btn_"+yEntreDeux_data.scriptName+": Button { preferredSize: ['"+YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+yEntreDeux_data.scriptName+"', helpTip:'"+yEntreDeux_data.scriptDesc+"' }"; this.resources =
{
} icon : new File('yNet.png'),
};
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//-------- this.init = function init()
// MAIN SCRIPT GOES HERE. {
function build_yEntreDeux_data_UI(){ this.btnLauyout =
//script info "button\
yEntreDeux_data = new Object(); {\
yEntreDeux_data.scriptName = 'yEntreDeux'; preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\
yEntreDeux_data.scriptVer = '0.1a'; text:'" + this.info.name + "',\
yEntreDeux_data.webLink = 'yorchnet.com'; helpTip:'" + this.info.description + "'\
}";
this. res =
// GUI "window { \
type:'palette' ,\
//chk_stretch: Checkbox { text:'Stretch', alignment:['fill','center'] , helpTip:'Stretch between parents'},\ text:'" + this.info.name + ' ' + this.info.version + "',\
margins:[10,10,10,10],\
yEntreDeux_data.res= "window { \ spacing:[5,5,5,5]\
type:'palette' , text:'"+yEntreDeux_data.scriptName+' '+yEntreDeux_data.scriptVer+"',margins:[10,10,10,10],spacing:[5,5,5,5]\
\
lst_layer: DropDownList {title:'layer to constrain',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the layer you wish to constrain'}\
lst_pa: DropDownList {title:'parent a',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the first parent'}\
lst_pb: DropDownList {title:'parent b',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the second parent'}\
exec_btn: Button {text:'do It',preferredSize:[150,35],helpTip:'do it'}\
\
info: Group { \
alignment:['center','bottom'], \
icon: Image {preferredSize: [15, 18]},\
website: StaticText { text:'"+yEntreDeux_data.webLink+"', alignment:['fill','center'] },\
}\
\ \
}"; lst_layer: DropDownList\
{\
title:'layer to constrain',\
yEntreDeux_data.window = new Window (yEntreDeux_data.res); preferredSize:[150,35],\
//never got around of assigning the icon any other way, but it works. textSelection:'Escoge',\
yEntreDeux_data.window.info.icon.image = YTB.icon; helpTip:'Select the layer you wish to constrain'\
}\
refresh(); // reloads the possible layers in the gui. lst_pa: DropDownList\
{\
yEntreDeux_data.window.exec_btn.onClick = run; title:'parent a',\
preferredSize:[150,35],\
textSelection:'Escoge',\
yEntreDeux_data.window.show(); helpTip:'Select the first parent'\
} }\
lst_pb: DropDownList\
function run(){ {\
app.beginUndoGroup('Bind Between Two'); title:'parent b',\
preferredSize:[150,35],\
selectedLayerName=String(yEntreDeux_data.window.lst_layer.selection); textSelection:'Escoge',\
parentALayerName=String(yEntreDeux_data.window.lst_pa.selection); helpTip:'Select the second parent'\
parentBLayerName=String(yEntreDeux_data.window.lst_pb.selection); }\
layerN = selectedLayerName.substr(0, selectedLayerName.indexOf('.')); exec_btn: Button\
paN = parentALayerName.substr(0, parentALayerName.indexOf('.')); {\
pbN = parentBLayerName.substr(0, parentBLayerName.indexOf('.')); text:'do It',\
layer = app.project.activeItem.layers[layerN]; preferredSize:[150,35],\
pa = app.project.activeItem.layers[paN]; helpTip:'do it'\
pb = app.project.activeItem.layers[pbN]; }\
layer("Effects").addProperty("Layer Control"); info: Group\
layer("Effects")("Layer Control").name = 'ctrl01'; {\
layer("Effects")("ctrl01")("Layer").setValue(pa.index); alignment:['center','bottom'], \
layer("Effects").addProperty("Layer Control"); icon: Image {preferredSize: [15, 18]},\
layer("Effects")("Layer Control").name = 'ctrl02'; website: StaticText { text:'" + this.info.url + "', alignment:['fill','center'] },\
layer("Effects")("ctrl02")("Layer").setValue(pb.index); }\
layer("Effects").addProperty("Angle Control"); }";
layer("Effects")("Angle Control").name = 'offset'; }
layer("Effects")("offset")("Angle").setValue(0); this.createUI = function createUI()
layer("Effects").addProperty("Slider Control"); {
layer("Effects")("Slider Control").name = 'weight'; res =
layer("Effects")("weight")(1).setValue(50); "window {\
layer("Effects").addProperty("Checkbox Control"); resizeable : true\
layer("Effects")("Checkbox Control").name = 'stretch'; closeButton : true\
posExp = text:'wtf'\
'a = effect("ctrl01")("Layer");\ }"
b = effect("ctrl02")("Layer");\
aPos = a.toComp(a.anchorPoint);\ this.window = new Window( res );
bPos = b.toComp(b.anchorPoint);\ this.window.layout.layout(true);
w= effect("weight")(1)/100;\ this.window.center();
(aPos*(1-w)+bPos*(w))' this.window.show();
rotExp = }
'a =effect("ctrl01")("Layer");\ this.yMainFunction = function yMainFunction()
b = effect("ctrl02")("Layer");\ {
aPos = a.toComp(a.anchorPoint);\ this.createUI();
bPos = b.toComp(b.anchorPoint);\ }
rx = lookAt(aPos,bPos)[0];\ this.activate = function activate()
ry = lookAt(aPos,bPos)[1];\ {
offset = effect("offset")("Angle");\ this.yTool.yMainFunction();
if (aPos[1] > bPos[1])\
{\
(ry) -90 + offset\
}\
else\
{\
90 - (ry) + offset\
}'
scaleExp =
'a = effect("ctrl01")("Layer");\
b = effect("ctrl02")("Layer");\
aPos = a.toComp(a.anchorPoint);\
bPos = b.toComp(b.anchorPoint);\
d = Math.sqrt(Math.pow((aPos[0]-bPos[0]),2)+Math.pow((aPos[1]-bPos[1]),2));\
x = transform.scale[0];\
y = transform.scale[1];\
sx = ((d*100)/this.width)/100;\
stretch = effect("stretch")("Checkbox");\
if(stretch==true)\
{\
[x*sx,y]\
}\
else\
{\
[x,y]\
}'
layer.transform.position.expression = posExp;
layer.transform.rotation.expression= rotExp;
layer.transform.scale.expression= scaleExp;
app.endUndoGroup();
} }
function refresh(){
//alert('going');
lists=[yEntreDeux_data.window.lst_pa,yEntreDeux_data.window.lst_layer,yEntreDeux_data.window.lst_pb]//they should be in this order for the assignment of the selection index works right/
for(i=0;i<lists.length;i++){
lists[i].removeAll();
}
var sel = app.project.activeItem.selectedLayers;
var compLayers = app.project.activeItem.layers;
var selectableLayers = [];
for(i=1;i<=compLayers.length;i++){
selectableLayers.push(compLayers[i]);
}
var lst_layer = yEntreDeux_data.window.lst_layer;
var lst_pa = yEntreDeux_data.window.lst_pa;
var lst_pb = yEntreDeux_data.window.lst_pb;
for(i=0;i<lists.length;i++){
for(j=0;j<selectableLayers.length;j++){
lists[i].add('item',selectableLayers[j].index+"."+selectableLayers[j].name);
/*for(i=0;i<lists.length;i++){
lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
}*/
//alert(selectableLayers[i].name)
}
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
}
//var selIndex = sel[0].index-1;
lst_layer.selection = 0;
lst_pa.selection = 0;
lst_pb.selection = 0;
}
//build_yEntreDeux_UI();
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//-------- this.init();
/* return this;
function build_yEntreDeux_data_UI(){ }
yEntreDeux_data.window = new Window (yEntreDeux_data.res);
yEntreDeux_data.window.show();
}
*/
yEntreDeux_data.activate = build_yEntreDeux_data_UI ;
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. //CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
if (typeof(YTB)=='undefined'){ if (typeof(YTB)=='undefined')
yEntreDeux_data.activate(); {
}else{ yGenericTool = new YGenericTool();
} yGenericTool.activate();
}
else
{
YTB.addTool(new YGenericTool());
}

Loading…
Cancel
Save