mirror of
https://github.com/sbrow/ps.git
synced 2026-02-27 02:51:44 -05:00
Various updates
* Layersets now have bounds. * TextItem is now writeable * Added flush function to writing, for faster debugging.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include lib.js
|
||||
|
||||
var stdout = newFile(arguments[0]);
|
||||
var set = eval(arguments[1]);
|
||||
stdout.writeln('{"Name": "'+set.name+'", "ArtLayers":[');
|
||||
stdout.flush();
|
||||
for (var i = 0; i < set.artLayers.length; i++) {
|
||||
var lyr = set.artLayers[i];
|
||||
stdout.write(('{"Name":"' + lyr.name + '", "Bounds": [[' + lyr.bounds[0] + ',' +
|
||||
@@ -15,13 +15,25 @@ for (var i = 0; i < set.artLayers.length; i++) {
|
||||
stdout.write("}")
|
||||
if (i != set.artLayers.length - 1)
|
||||
stdout.writeln(",");
|
||||
stdout.flush();
|
||||
}
|
||||
stdout.write('], "LayerSets": [')
|
||||
stdout.writeln("]");
|
||||
stdout.write(', "LayerSets": [')
|
||||
for (var i = 0; i < set.layerSets.length; i++) {
|
||||
var s = set.layerSets[i];
|
||||
stdout.write('{"Name": "'+ s.name +'", "Visible": '+s.visible+'}');
|
||||
stdout.write('{"Name":"' + s.name + '", "Visible": ' + s.visible + '}');
|
||||
if (i < set.layerSets.length - 1)
|
||||
stdout.writeln(",");
|
||||
stdout.flush()
|
||||
}
|
||||
stdout.write("]}")
|
||||
stdout.writeln(']')
|
||||
// app.activeDocument.activeLayer=set;
|
||||
// set.merge();
|
||||
// set=eval(arguments[2]);
|
||||
stdout.write(', "Bounds": [[],[]]');
|
||||
// stdout.write((', "Bounds": [[' + set.bounds[0] + ',' +
|
||||
// set.bounds[1] + '],[' + set.bounds[2] + ',' +
|
||||
// set.bounds[3] + ']]').replace(/ px/g, ""));
|
||||
stdout.write("}");
|
||||
// Undo();
|
||||
stdout.close();
|
||||
@@ -1,13 +1,21 @@
|
||||
// Opens and returns a file, overwriting new data.
|
||||
function newFile(path) {
|
||||
var f = File(path)
|
||||
if(f.exists)
|
||||
f.remove()
|
||||
f.encoding = "UTF8"
|
||||
f.open("e", "TEXT", "????")
|
||||
f.open("w")
|
||||
return f
|
||||
}
|
||||
|
||||
File.prototype.flush = function() {
|
||||
this.close()
|
||||
this.open("a")
|
||||
};
|
||||
function flush(file) {
|
||||
file.close()
|
||||
file.open("a")
|
||||
}
|
||||
|
||||
|
||||
// Prints an error message.
|
||||
function err(e) {
|
||||
return 'ERROR: ' + e.message + ' at ' + e.fileName + ':' + e.line;
|
||||
@@ -19,6 +27,14 @@ function bounds(lyr) {
|
||||
lyr.bounds[3] + ']]').replace(/ px/g, "");
|
||||
}
|
||||
|
||||
function Undo() {
|
||||
var desc = new ActionDescriptor();
|
||||
var ref = new ActionReference();
|
||||
ref.putEnumerated( charIDToTypeID( "HstS" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Prvs" ));
|
||||
desc.putReference(charIDToTypeID( "null" ), ref);
|
||||
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
|
||||
}
|
||||
|
||||
/**
|
||||
* The setFormatting function sets the font, font style, point size, and RGB color of specified
|
||||
* characters in a Photoshop text layer.
|
||||
|
||||
@@ -2,5 +2,12 @@
|
||||
var stdout = newFile(arguments[0]);
|
||||
var lyr = eval(arguments[1]);
|
||||
lyr.translate((Number)(arguments[2]), (Number)(arguments[3]));
|
||||
if (lyr.typename == 'LayerSet') {
|
||||
alert(lyr.name + "\n" + lyr.typename)
|
||||
alert(lyr)
|
||||
// lyr.merge()
|
||||
// lyr=eval(arguments[4])
|
||||
// Undo();
|
||||
}
|
||||
stdout.writeln('{' + bounds(lyr) + '}')
|
||||
stdout.close();
|
||||
@@ -1,12 +1,11 @@
|
||||
#include lib.js
|
||||
var saveFile = File(arguments[0]);
|
||||
if(saveFile.exists)
|
||||
saveFile.remove();
|
||||
|
||||
saveFile.encoding = "UTF8";
|
||||
saveFile.open("e", "TEXT", "????");
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
saveFile.writeln(arguments[i])
|
||||
}
|
||||
setFormatting(0,6, "Arial", "Bold");
|
||||
saveFile.close();
|
||||
// var saveFile = File(arguments[0]);
|
||||
var arg = 'app.activeDocument.layerSets.getByName("Indicators").layerSets.getByName("Deck")';
|
||||
alert(arg.replace(/[^(?:layerSets)]*(layerSets)/, "artLayers"))
|
||||
// var doc=app.activeDocument
|
||||
// doc.layerSets.getByName("ResolveGem").merge();
|
||||
// alert(doc.artLayers.getByName("ResolveGem").bounds);
|
||||
// doc.activeHistoryState=doc.historyStates[doc.historyStates.length-2]
|
||||
// setFormatting(0,6, "Arial", "Bold");
|
||||
// saveFile.close();
|
||||
Reference in New Issue
Block a user