Added a TextItem Struct to Artlayers.

* Converted scripts to use the same getLayers() function from lib.js
This commit is contained in:
Unknown
2018-04-26 13:09:36 -04:00
parent e136ea8a83
commit 40cde546bc
8 changed files with 179 additions and 85 deletions

View File

@@ -97,4 +97,26 @@ function setFormatting(start, end, fontName, fontStyle, fontSize, colorArray) {
}
}
}
}
function layers(lyrs) {
if (typeof lyrs === 'undefined')
return;
var str = "";
for (var i = 0; i < lyrs.length; i++) {
var lyr = lyrs[i];
str += ('{"Name":"' + lyr.name + '", "Bounds": [[' + lyr.bounds[0] + ',' +
lyr.bounds[1] + '],[' + lyr.bounds[2] + ',' +
lyr.bounds[3] + ']], "Visible": ' + lyr.visible+', "TextItem": ').replace(/ px/g, "");
if (lyr.kind == LayerKind.TEXT) {
str += ('{"Contents": "'+lyr.textItem.contents+'",').replace(/\r/g, '\\r');
str += (' "Size": '+lyr.textItem.size+',').replace(/ pt/g, '');
str += ' "Font": "'+lyr.textItem.font+'"}\n'
} else
str += "null";
str += "}";
if (i+1 != lyrs.length)
str += ',';
}
return str
}