|
|
|
@ -1,89 +1,120 @@
|
|
|
|
yColorProbe_data = new Object();
|
|
|
|
#include "../yScripts/y_JSExtensions.jsx";
|
|
|
|
|
|
|
|
#include "usefulFunctions.jsx";
|
|
|
|
|
|
|
|
|
|
|
|
yColorProbe_data.scriptName = 'yColorProbe';
|
|
|
|
function YColorProbe()
|
|
|
|
yColorProbe_data.scriptDesc = 'Creates a Null that will Sample the selected layer within the specified radius.';
|
|
|
|
{
|
|
|
|
yColorProbe_data.scriptVer = '0.2a';
|
|
|
|
this.info =
|
|
|
|
yColorProbe_data.webLink = 'yorchnet.com';
|
|
|
|
{
|
|
|
|
|
|
|
|
name : "yColorProbe",
|
|
|
|
//if yToolBox Exists add it to its tool list.
|
|
|
|
version : 0.0,
|
|
|
|
if (typeof(YTB)!=='undefined'){
|
|
|
|
stage : "development",
|
|
|
|
YTB.tools.push(yColorProbe_data);
|
|
|
|
description : "Creates a Null that will Sample the selected layer within the specified radius.",
|
|
|
|
|
|
|
|
url : "yorchnet.com"
|
|
|
|
//it should be called from toolbox.
|
|
|
|
};
|
|
|
|
/* yColorProbe_data.buttonWidth=76;
|
|
|
|
this.appearence =
|
|
|
|
yColorProbe_data.buttonHeight=30;
|
|
|
|
{
|
|
|
|
*/
|
|
|
|
buttonHeight : 30,
|
|
|
|
yColorProbe_data.btnLayout = "btn_"+yColorProbe_data.scriptName+": Button { preferredSize: ['"+ YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+yColorProbe_data.scriptName+"', helpTip:'"+yColorProbe_data.scriptDesc+"' }";
|
|
|
|
buttonWidth : 126
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.resources =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
icon : new File('yNet.png'),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.init = function init()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.btnLauyout =
|
|
|
|
|
|
|
|
"button\
|
|
|
|
|
|
|
|
{\
|
|
|
|
|
|
|
|
preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\
|
|
|
|
|
|
|
|
text:'" + this.info.name + "',\
|
|
|
|
|
|
|
|
helpTip:'" + this.info.description + "'\
|
|
|
|
|
|
|
|
}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this. res =
|
|
|
|
|
|
|
|
"window\
|
|
|
|
|
|
|
|
{\
|
|
|
|
|
|
|
|
type:'palette',\
|
|
|
|
|
|
|
|
text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\
|
|
|
|
|
|
|
|
info: Group \
|
|
|
|
|
|
|
|
{\
|
|
|
|
|
|
|
|
alignment:['center','bottom'],\
|
|
|
|
|
|
|
|
icon: Image \
|
|
|
|
|
|
|
|
{\
|
|
|
|
|
|
|
|
icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\
|
|
|
|
|
|
|
|
preferredSize: [15, 18]\
|
|
|
|
|
|
|
|
},\
|
|
|
|
|
|
|
|
website: StaticText\
|
|
|
|
|
|
|
|
{\
|
|
|
|
|
|
|
|
text:'" + this.info.url + "',\
|
|
|
|
|
|
|
|
alignment:['fill','center']\
|
|
|
|
|
|
|
|
},\
|
|
|
|
|
|
|
|
}\
|
|
|
|
|
|
|
|
}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getInfo = function getInfo( )
|
|
|
|
yColorProbe_data.res = "window { \
|
|
|
|
{
|
|
|
|
type:'palette' , text:'"+yColorProbe_data.scriptName+' '+yColorProbe_data.scriptVer+"',\
|
|
|
|
alert("asdasdasd");
|
|
|
|
\
|
|
|
|
}
|
|
|
|
\
|
|
|
|
this.createUI = function createUI()
|
|
|
|
info: Group { \
|
|
|
|
{
|
|
|
|
alignment:['center','bottom'], \
|
|
|
|
this.window = new Window ( this.res );
|
|
|
|
icon: Image {preferredSize: [15, 18]},\
|
|
|
|
this.window.show() ;
|
|
|
|
website: StaticText { text:'"+yColorProbe_data.webLink+"', alignment:['fill','center'] },\
|
|
|
|
}
|
|
|
|
}\
|
|
|
|
this.yMainFunction = function yMainFunction()
|
|
|
|
\
|
|
|
|
{
|
|
|
|
}";
|
|
|
|
app.beginUndoGroup(this.yTool.info.name); // yTool is a refernece to the Tool object, because THIS in this context returns the ButtonObject....
|
|
|
|
|
|
|
|
|
|
|
|
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
|
|
|
|
|
|
// MAIN SCRIPT GOES HERE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "usefulFunctions.jsx";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function yColorProbe(){
|
|
|
|
|
|
|
|
//It works with Sampled layers at a 100% scale only.
|
|
|
|
//It works with Sampled layers at a 100% scale only.
|
|
|
|
app.beginUndoGroup('Create ColorProbe');
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sel = app.project.activeItem.selectedLayers[0];
|
|
|
|
sel = app.project.activeItem.selectedLayers[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err)
|
|
|
|
catch (err)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sel = undefined;
|
|
|
|
sel = undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
myNull = app.project.activeItem.layers.addNull();
|
|
|
|
|
|
|
|
myNull.transform.anchorPoint.setValue([50,50]);
|
|
|
|
|
|
|
|
myNull.name = yUniStr('colorProbe'); //Generates a Unique Name by adding numbers at the end of the main string.
|
|
|
|
|
|
|
|
layerCTRL = myNull("Effects").addProperty("Layer Control");
|
|
|
|
|
|
|
|
layerCTRL.name='sampledLayer';
|
|
|
|
|
|
|
|
colorCTRL = myNull("Effects").addProperty("Color Control");
|
|
|
|
|
|
|
|
colorCTRL.name='outColor';
|
|
|
|
|
|
|
|
radiusCTRL = myNull("Effects").addProperty("Slider Control");
|
|
|
|
|
|
|
|
radiusCTRL.name ='radius';
|
|
|
|
|
|
|
|
myNull("Effects")("radius")('Slider').setValue(5);
|
|
|
|
|
|
|
|
colExp = 'myLayer = thisLayer("Effects")("sampledLayer")("Layer");\
|
|
|
|
|
|
|
|
p = thisLayer.toWorld(thisLayer.transform.anchorPoint);\
|
|
|
|
|
|
|
|
r = thisLayer("Effects")("radius")("Slider");\
|
|
|
|
|
|
|
|
myLayer.sampleImage(p, radius = [r, r], postEffect=true, t=time)';
|
|
|
|
|
|
|
|
myNull("Effects")('outColor')('Color').expression=colExp;
|
|
|
|
|
|
|
|
myNull.label=2;
|
|
|
|
|
|
|
|
myNull.source.height=30;
|
|
|
|
|
|
|
|
myNull.source.width=30;
|
|
|
|
|
|
|
|
myNull.anchorPoint=(15,15);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(sel!==undefined){
|
|
|
|
myNull = app.project.activeItem.layers.addNull();
|
|
|
|
myNull("Effects")('sampledLayer')(1).setValue(sel.index);
|
|
|
|
myNull.transform.anchorPoint.setValue([50,50]);
|
|
|
|
}
|
|
|
|
myNull.name = yUniStr('colorProbe'); //Generates a Unique Name by adding numbers at the end of the main string.
|
|
|
|
app.endUndoGroup();
|
|
|
|
layerCTRL = myNull("Effects").addProperty("Layer Control");
|
|
|
|
return 'ok'
|
|
|
|
layerCTRL.name='sampledLayer';
|
|
|
|
|
|
|
|
colorCTRL = myNull("Effects").addProperty("Color Control");
|
|
|
|
|
|
|
|
colorCTRL.name='outColor';
|
|
|
|
|
|
|
|
radiusCTRL = myNull("Effects").addProperty("Slider Control");
|
|
|
|
|
|
|
|
radiusCTRL.name ='radius';
|
|
|
|
|
|
|
|
myNull("Effects")("radius")('Slider').setValue(5);
|
|
|
|
|
|
|
|
colExp = 'myLayer = thisLayer("Effects")("sampledLayer")("Layer");\
|
|
|
|
|
|
|
|
p = thisLayer.toWorld(thisLayer.transform.anchorPoint);\
|
|
|
|
|
|
|
|
r = thisLayer("Effects")("radius")("Slider");\
|
|
|
|
|
|
|
|
myLayer.sampleImage(p, radius = [r, r], postEffect=true, t=time)';
|
|
|
|
|
|
|
|
myNull("Effects")('outColor')('Color').expression=colExp;
|
|
|
|
|
|
|
|
myNull.label=2;
|
|
|
|
|
|
|
|
myNull.source.height=30;
|
|
|
|
|
|
|
|
myNull.source.width=30;
|
|
|
|
|
|
|
|
myNull.anchorPoint=(15,15);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(sel!==undefined){
|
|
|
|
|
|
|
|
myNull("Effects")('sampledLayer')(1).setValue(sel.index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.endUndoGroup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
|
|
this.activate = this.yMainFunction;
|
|
|
|
|
|
|
|
|
|
|
|
function build_yColorProbe_data_UI(){
|
|
|
|
this.init();
|
|
|
|
yColorProbe_data.window = new Window ( yColorProbe_data.res);
|
|
|
|
return this;
|
|
|
|
yColorProbe_data.window.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yColorProbe_data.activate =yColorProbe ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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')
|
|
|
|
yColorProbe_data.activate();
|
|
|
|
{
|
|
|
|
}else{
|
|
|
|
yColorProbe = new YColorProbe();
|
|
|
|
}
|
|
|
|
yColorProbe.activate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
YTB.addTool(new YColorProbe());
|
|
|
|
|
|
|
|
}
|
|
|
|
|