Hello Goodnight!.
I have the same problem, I would like it not to redraw what is in the Script, just see the final image.
I would like to know if I could do something to improve the performance of this scrip which takes about 10 seconds on my machine.
I know the code is not very good writen, I don't know if this affects performance very much.
Code: Select all
if ( obj.xscheme == "m4" ) {
//| alert("m4 - tetrad")
//|------------------------------------------------------------------------------------------------------------------------------------
//| Color Primario
// var w = 0; // px
var nLastProgress = 20;
var progressWindow = createProgressWindow("Progress...", 0, nLastProgress, true, false);
progressWindow.isDone = false;
progressWindow.onCancel = function() {
this.isDone = true;
return true; // return 'true' to close the window
}
try {
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var x = activeDocument.width.value/2;
var y = activeDocument.height.value/3;
var despXY = activeDocument.height.value/9;
app.preferences.rulerUnits = tmp;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("contentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
//| Posición y forma
var d2 = new ActionDescriptor();
var nTop = 0+despXY;
var nLeft = 0+despXY;
var nBottom = y+despXY;
var nRight = (y/2)+despXY;
var oColorBox = new SolidColor();
oColorBox.rgb.red = obj.scheme.primary.col[0].r;
oColorBox.rgb.green = obj.scheme.primary.col[0].g;
oColorBox.rgb.blue = obj.scheme.primary.col[0].b;
d2.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), nTop);
d2.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), nLeft);
d2.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"), nBottom);
d2.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), nRight);
d1.putObject(stringIDToTypeID("shape"), stringIDToTypeID("rectangle"), d2);
//| Color de Fill
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID('red'), obj.scheme.primary.col[0].r);
d3.putDouble(stringIDToTypeID('green'), obj.scheme.primary.col[0].g);
d3.putDouble(stringIDToTypeID('blue'), obj.scheme.primary.col[0].b);
var d2 = new ActionDescriptor();
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
var d4 = new ActionDescriptor();
d4.putBoolean(stringIDToTypeID('fillEnabled'), true);
d1.putObject(stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), d4);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
//| Rasterize
var idrasterizeLayer = stringIDToTypeID( "rasterizeLayer" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref4.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref4 );
var idWhat = charIDToTypeID( "What" );
var idrasterizeItem = stringIDToTypeID( "rasterizeItem" );
var idlayerStyle = stringIDToTypeID( "layerStyle" );
desc5.putEnumerated( idWhat, idrasterizeItem, idlayerStyle );
executeAction( idrasterizeLayer, desc5, DialogModes.NO );
var doc = activeDocument;
doc.activeLayer.name = "primary";
//| Mover el layer al principio.
var currentLayer = app.activeDocument.activeLayer; // get just moved layer
var stackDoc = app.activeDocument;
app.activeDocument.activeLayer.move( stackDoc, ElementPlacement.PLACEATBEGINNING ); // move it
//| update progress
progressWindow.text = ("Processing " + 1 + " of " + nLastProgress + "...");
progressWindow.updateProgress(1);
//| Texto | "m2" | complement | Color Primario |
//| Porcentaje
nBottom = (y*.42)+despXY;
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 2 + " of " + nLastProgress + "...");
progressWindow.updateProgress(2);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nLeft + (nRight-nLeft)/4, nTop + ((nBottom-nTop)/2) + (nSizeText*0.33) );
textProperty.contents = "42%";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 3 + " of " + nLastProgress + "...");
progressWindow.updateProgress(3);
//| RGB + HSB
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
fontLeading(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 4 + " of " + nLastProgress + "...");
progressWindow.updateProgress(4);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nRight - (nRight-nLeft)/15, nTop + ((nBottom-nTop)/2) - (nSizeText*0.66) );
textProperty.contents = rgbToHex(parseInt(oColorBox.rgb.red),parseInt(oColorBox.rgb.green),parseInt(oColorBox.rgb.blue)) + "\r" +
"RGB(" + oColorBox.rgb.red + "," + oColorBox.rgb.green + "," + oColorBox.rgb.blue + ")" + "\r" +
"HSB(" + Math.round(oColorBox.hsb.hue) + "," + Math.round(oColorBox.hsb.saturation) + "," + Math.round(oColorBox.hsb.brightness) + ")";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 5 + " of " + nLastProgress + "...");
progressWindow.updateProgress(5);
//| ------------------------------------------------------------------------------------------------------------------------------------
//| Color Secundario A
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var x = activeDocument.width.value/2;
var y = activeDocument.height.value/3;
var despXY = activeDocument.height.value/9;
app.preferences.rulerUnits = tmp;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("contentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
//| Posición y forma
var d2 = new ActionDescriptor();
var nTop = (y*.42)+despXY;
var nLeft = 0+despXY;
var nBottom = y+despXY;
var nRight = (y/2)+despXY;
var oColorBox = new SolidColor();
oColorBox.rgb.red = obj.scheme.complement.col[0].r;
oColorBox.rgb.green = obj.scheme.complement.col[0].g;
oColorBox.rgb.blue = obj.scheme.complement.col[0].b;
d2.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), nTop);
d2.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), nLeft);
d2.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"), nBottom);
d2.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), nRight);
d1.putObject(stringIDToTypeID("shape"), stringIDToTypeID("rectangle"), d2);
//| Color de Fill
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID('red'), obj.scheme.complement.col[0].r);
d3.putDouble(stringIDToTypeID('green'), obj.scheme.complement.col[0].g);
d3.putDouble(stringIDToTypeID('blue'), obj.scheme.complement.col[0].b);
var d2 = new ActionDescriptor();
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
var d4 = new ActionDescriptor();
d4.putBoolean(stringIDToTypeID('fillEnabled'), true);
d1.putObject(stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), d4);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
//| Rasterize
var idrasterizeLayer = stringIDToTypeID( "rasterizeLayer" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref4.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref4 );
var idWhat = charIDToTypeID( "What" );
var idrasterizeItem = stringIDToTypeID( "rasterizeItem" );
var idlayerStyle = stringIDToTypeID( "layerStyle" );
desc5.putEnumerated( idWhat, idrasterizeItem, idlayerStyle );
executeAction( idrasterizeLayer, desc5, DialogModes.NO );
//var doc = activeDocument;
//doc.activeLayer.name = "complement";
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 6 + " of " + nLastProgress + "...");
progressWindow.updateProgress(6);
//| Texto | "m2" | complement | Color Complementario |
//| Porcentaje
nBottom = (y*.60)+despXY;
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 7 + " of " + nLastProgress + "...");
progressWindow.updateProgress(7);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nLeft + (nRight-nLeft)/4, nTop + ((nBottom-nTop)/2) + (nSizeText*0.33) );
textProperty.contents = "18%";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 8 + " of " + nLastProgress + "...");
progressWindow.updateProgress(8);
//| RGB + HSB
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
fontLeading(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 9 + " of " + nLastProgress + "...");
progressWindow.updateProgress(9);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nRight - (nRight-nLeft)/15, nTop + ((nBottom-nTop)/2) - (nSizeText*0.66) );
textProperty.contents = rgbToHex(parseInt(oColorBox.rgb.red),parseInt(oColorBox.rgb.green),parseInt(oColorBox.rgb.blue)) + "\r" +
"RGB(" + oColorBox.rgb.red + "," + oColorBox.rgb.green + "," + oColorBox.rgb.blue + ")" + "\r" +
"HSB(" + Math.round(oColorBox.hsb.hue) + "," + Math.round(oColorBox.hsb.saturation) + "," + Math.round(oColorBox.hsb.brightness) + ")";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//var doc = activeDocument;
//doc.activeLayer.name = "CSD3 - complement";
//| update progress
progressWindow.text = ("Processing " + 10 + " of " + nLastProgress + "...");
progressWindow.updateProgress(10);
//| ------------------------------------------------------------------------------------------------------------------------------------
//| Color Secundario B
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var x = activeDocument.width.value/2;
var y = activeDocument.height.value/3;
var despXY = activeDocument.height.value/9;
app.preferences.rulerUnits = tmp;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("contentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
//| Posición y forma
var d2 = new ActionDescriptor();
var nTop = (y*.60)+despXY;
var nLeft = 0+despXY;
var nBottom = y+despXY;
var nRight = (y/2)+despXY;
var oColorBox = new SolidColor();
oColorBox.rgb.red = obj.scheme.secondarya.col[0].r;
oColorBox.rgb.green = obj.scheme.secondarya.col[0].g;
oColorBox.rgb.blue = obj.scheme.secondarya.col[0].b;
d2.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), nTop);
d2.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), nLeft);
d2.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"), nBottom);
d2.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), nRight);
d1.putObject(stringIDToTypeID("shape"), stringIDToTypeID("rectangle"), d2);
//| Color de Fill
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID('red'), obj.scheme.secondarya.col[0].r);
d3.putDouble(stringIDToTypeID('green'), obj.scheme.secondarya.col[0].g);
d3.putDouble(stringIDToTypeID('blue'), obj.scheme.secondarya.col[0].b);
var d2 = new ActionDescriptor();
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
var d4 = new ActionDescriptor();
d4.putBoolean(stringIDToTypeID('fillEnabled'), true);
d1.putObject(stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), d4);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
//| Rasterize
var idrasterizeLayer = stringIDToTypeID( "rasterizeLayer" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref4.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref4 );
var idWhat = charIDToTypeID( "What" );
var idrasterizeItem = stringIDToTypeID( "rasterizeItem" );
var idlayerStyle = stringIDToTypeID( "layerStyle" );
desc5.putEnumerated( idWhat, idrasterizeItem, idlayerStyle );
executeAction( idrasterizeLayer, desc5, DialogModes.NO );
//var doc = activeDocument;
//doc.activeLayer.name = "complement";
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 11 + " of " + nLastProgress + "...");
progressWindow.updateProgress(11);
//| Texto
//| Porcentaje
nBottom = (y*.88)+despXY;
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 12 + " of " + nLastProgress + "...");
progressWindow.updateProgress(12);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nLeft + (nRight-nLeft)/4, nTop + ((nBottom-nTop)/2) + (nSizeText*0.33) );
textProperty.contents = "28%";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 13 + " of " + nLastProgress + "...");
progressWindow.updateProgress(13);
//| RGB + HSB
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
fontLeading(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 14 + " of " + nLastProgress + "...");
progressWindow.updateProgress(14);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nRight - (nRight-nLeft)/15, nTop + ((nBottom-nTop)/2) - (nSizeText*0.66) );
textProperty.contents = rgbToHex(parseInt(oColorBox.rgb.red),parseInt(oColorBox.rgb.green),parseInt(oColorBox.rgb.blue)) + "\r" +
"RGB(" + oColorBox.rgb.red + "," + oColorBox.rgb.green + "," + oColorBox.rgb.blue + ")" + "\r" +
"HSB(" + Math.round(oColorBox.hsb.hue) + "," + Math.round(oColorBox.hsb.saturation) + "," + Math.round(oColorBox.hsb.brightness) + ")";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//var doc = activeDocument;
//doc.activeLayer.name = "CSD3 - complement";
//| update progress
progressWindow.text = ("Processing " + 15 + " of " + nLastProgress + "...");
progressWindow.updateProgress(15);
//| ------------------------------------------------------------------------------------------------------------------------------------
//| Color Complementario
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var x = activeDocument.width.value/2;
var y = activeDocument.height.value/3;
var despXY = activeDocument.height.value/9;
app.preferences.rulerUnits = tmp;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("contentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
//| Posición y forma
var d2 = new ActionDescriptor();
var nTop = (y*.88)+despXY;
var nLeft = 0+despXY;
var nBottom = y+despXY;
var nRight = (y/2)+despXY;
var oColorBox = new SolidColor();
oColorBox.rgb.red = obj.scheme.secondaryb.col[0].r;
oColorBox.rgb.green = obj.scheme.secondaryb.col[0].g;
oColorBox.rgb.blue = obj.scheme.secondaryb.col[0].b;
d2.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), nTop);
d2.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), nLeft);
d2.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"), nBottom);
d2.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), nRight);
d1.putObject(stringIDToTypeID("shape"), stringIDToTypeID("rectangle"), d2);
//| Color de Fill
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID('red'), obj.scheme.secondaryb.col[0].r);
d3.putDouble(stringIDToTypeID('green'), obj.scheme.secondaryb.col[0].g);
d3.putDouble(stringIDToTypeID('blue'), obj.scheme.secondaryb.col[0].b);
var d2 = new ActionDescriptor();
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
var d4 = new ActionDescriptor();
d4.putBoolean(stringIDToTypeID('fillEnabled'), true);
d1.putObject(stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), d4);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
//| Rasterize
var idrasterizeLayer = stringIDToTypeID( "rasterizeLayer" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref4.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref4 );
var idWhat = charIDToTypeID( "What" );
var idrasterizeItem = stringIDToTypeID( "rasterizeItem" );
var idlayerStyle = stringIDToTypeID( "layerStyle" );
desc5.putEnumerated( idWhat, idrasterizeItem, idlayerStyle );
executeAction( idrasterizeLayer, desc5, DialogModes.NO );
//var doc = activeDocument;
//doc.activeLayer.name = "complement";
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 16 + " of " + nLastProgress + "...");
progressWindow.updateProgress(16);
//| Texto
//| Porcentaje
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 17 + " of " + nLastProgress + "...");
progressWindow.updateProgress(17);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nLeft + (nRight-nLeft)/4, nTop + ((nBottom-nTop)/2) + (nSizeText*0.33) );
textProperty.contents = "12%";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
//| update progress
progressWindow.text = ("Processing " + 18 + " of " + nLastProgress + "...");
progressWindow.updateProgress(18);
//| RGB + HSB
var thisLayer = activeDocument.artLayers.add();
thisLayer.kind = LayerKind.TEXT;
thisLayer.name = "Texto";
thisLayer.blendMode = BlendMode.NORMAL;
thisLayer.opacity = 100;
var textProperty = thisLayer.textItem;
textProperty.kind = TextType.POINTTEXT;
textProperty.size = nSizeText;
fontSize(nSizeText);
fontLeading(nSizeText);
//| update progress
progressWindow.text = ("Processing " + 19 + " of " + nLastProgress + "...");
progressWindow.updateProgress(19);
textProperty.font = "ArialMT";
textProperty.color = newColor;
textProperty.position = new Array( nRight - (nRight-nLeft)/15, nTop + ((nBottom-nTop)/2) - (nSizeText*0.66) );
textProperty.contents = rgbToHex(parseInt(oColorBox.rgb.red),parseInt(oColorBox.rgb.green),parseInt(oColorBox.rgb.blue)) + "\r" +
"RGB(" + oColorBox.rgb.red + "," + oColorBox.rgb.green + "," + oColorBox.rgb.blue + ")" + "\r" +
"HSB(" + Math.round(oColorBox.hsb.hue) + "," + Math.round(oColorBox.hsb.saturation) + "," + Math.round(oColorBox.hsb.brightness) + ")";
textProperty.justification = Justification.RIGHT;
fontSombra();
app.activeDocument.activeLayer.merge();
var doc = activeDocument;
doc.activeLayer.name = "CSD3 - tetrad";
//| update progress
progressWindow.text = ("Processing " + 20 + " of " + nLastProgress + "...");
progressWindow.updateProgress(20);
} catch (e) {
alert(e);
} finally {
progressWindow.close();
}
}
----------------------
function fontSize(v) {
function sTT(v) {return stringIDToTypeID(v)} (ref1 = new ActionReference()).putProperty(sTT('property'), tS = sTT('textStyle'))
ref1.putEnumerated(sTT('textLayer'), sTT('ordinal'), sTT('targetEnum')); (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(dsc2 = new ActionDescriptor()).putInteger(sTT('textOverrideFeatureName'), 808465458), dsc2.putInteger(sTT('typeStyleOperationType'), 3)
dsc2.putUnitDouble(sTT('size'), sTT('pixelsUnit'), v), dsc1.putObject(sTT('to'), tS, dsc2), executeAction(sTT('set'), dsc1, DialogModes.NO);
}
function fontLeading(v) {
function sTT(v) {return stringIDToTypeID(v)} (ref1 = new ActionReference()).putProperty(sTT('property'), tS = sTT('textStyle'))
ref1.putEnumerated(sTT('textLayer'), sTT('ordinal'), sTT('targetEnum')); (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(dsc2 = new ActionDescriptor()).putInteger(sTT('textOverrideFeatureName'), 808465461), dsc2.putInteger(sTT('typeStyleOperationType'), 3)
dsc2.putUnitDouble(sTT('leading'), sTT('pixelsUnit'), v), dsc1.putObject(sTT('to'), tS, dsc2), executeAction(sTT('set'), dsc1, DialogModes.NO);
}
/**
* rgbToHex
* @param number r Red value
* @param number g Green value
* @param number b Blue value
* @return string hexacimal value
* @usage //alert( rgbToHex(0, 51, 255) ); // #0033ff
*/
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
/**
* componentToHex convert two digit htx value to R, G or B chanel value
* @param number c value from 0 to 225
* @return string value of R, G or B chanel
* @usage //alert (componentToHex(255)); //ff
*/
function componentToHex(c) {
var hex = c.toString(16);
var regresa = hex.length == 1 ? "0" + hex : hex;
regresa = regresa.toUpperCase();
return regresa;
}
function fontSombra() {
var idsetd = charIDToTypeID( "setd" );
var desc365 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref35 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref35.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref35.putEnumerated( idLyr, idOrdn, idTrgt );
desc365.putReference( idnull, ref35 );
var idT = charIDToTypeID( "T " );
var desc366 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc366.putUnitDouble( idScl, idPrc, 416.666667 );
var idDrSh = charIDToTypeID( "DrSh" );
var desc367 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc367.putBoolean( idenab, true );
var idpresent = stringIDToTypeID( "present" );
desc367.putBoolean( idpresent, true );
var idshowInDialog = stringIDToTypeID( "showInDialog" );
desc367.putBoolean( idshowInDialog, true );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
var idMltp = charIDToTypeID( "Mltp" );
desc367.putEnumerated( idMd, idBlnM, idMltp );
var idClr = charIDToTypeID( "Clr " );
var desc368 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc368.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc368.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc368.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc367.putObject( idClr, idRGBC, desc368 );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc367.putUnitDouble( idOpct, idPrc, 100.000000 );
var iduglg = charIDToTypeID( "uglg" );
desc367.putBoolean( iduglg, true );
var idlagl = charIDToTypeID( "lagl" );
var idAng = charIDToTypeID( "#Ang" );
desc367.putUnitDouble( idlagl, idAng, 90.000000 );
var idDstn = charIDToTypeID( "Dstn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc367.putUnitDouble( idDstn, idPxl, 3.000000 );
var idCkmt = charIDToTypeID( "Ckmt" );
var idPxl = charIDToTypeID( "#Pxl" );
desc367.putUnitDouble( idCkmt, idPxl, 0.000000 );
var idblur = charIDToTypeID( "blur" );
var idPxl = charIDToTypeID( "#Pxl" );
desc367.putUnitDouble( idblur, idPxl, 7.000000 );
var idNose = charIDToTypeID( "Nose" );
var idPrc = charIDToTypeID( "#Prc" );
desc367.putUnitDouble( idNose, idPrc, 0.000000 );
var idAntA = charIDToTypeID( "AntA" );
desc367.putBoolean( idAntA, false );
var idTrnS = charIDToTypeID( "TrnS" );
var desc369 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc369.putString( idNm, """Linear""" );
var idShpC = charIDToTypeID( "ShpC" );
desc367.putObject( idTrnS, idShpC, desc369 );
var idlayerConceals = stringIDToTypeID( "layerConceals" );
desc367.putBoolean( idlayerConceals, true );
var idDrSh = charIDToTypeID( "DrSh" );
desc366.putObject( idDrSh, idDrSh, desc367 );
var idgagl = charIDToTypeID( "gagl" );
var idAng = charIDToTypeID( "#Ang" );
desc366.putUnitDouble( idgagl, idAng, 140.000000 );
var idLefx = charIDToTypeID( "Lefx" );
desc365.putObject( idT, idLefx, desc366 );
executeAction( idsetd, desc365, DialogModes.NO );
}