main(); function main () { /*** create document ***/ var phw = 200; // variable that holds the width/height of the page var doc = app.documents.add(); doc.documentPreferences.pageWidth = phw; doc.documentPreferences.pageHeight = phw; doc.documentPreferences.facingPages = false; var page = doc.pages.item(0); /*** create swatches for the first textframe ***/ var colors1 = new Array(); // array that holds the swatches var colors2 = new Array(); // another that holds the swatches var section = 5; for(var i=0; i www.exljbris.com */ // create textframe var tf = page.textFrames.add({ geometricBounds: [topLeft, topLeft, rightBottom, rightBottom], contents: 'a' }); var firstChar = tf.characters.firstItem(); //firstChar.appliedFont = myfont; firstChar.leading = 8; tf.contents = TextFrameContents.PLACEHOLDER_TEXT; /*** Apply colour to the characters ***/ var chars = tf.characters; // all characters for(var j = 0; j <= (chars.length-section); j = j + section){ for(var k=0; k < section; k++){ $.writeln("Character: " + (j + k) + " apply Swatch: " + k); chars[j+k].fillColor = colors1[k].color; } } /*** Duplicate layer ***/ var originalLayer = doc.layers.item(0); // get the first layer var duplicatedLayer = originalLayer.duplicate(); // duplicate the existing layer originalLayer.name = "Outer Shape"; // rename original layer duplicatedLayer.name = "Inner Shape"; // rename duplicated layer /*** Apply colour to the characters on the duplicated layer***/ var dup_tf = page.textFrames.item(1); // get textframe on duplicated layer var dup_chars = dup_tf.characters; // all characters for(var l = 0; l <= (dup_chars.length-section); l = l + section){ for(var m=0; m < section; m++){ $.writeln("Character: " + (l + m) + " apply Swatch: " + m); dup_chars[l+m].fillColor = colors2[m].color; } } /*** create cutout-shape ***/ var cutout_topLeft = 0 + 20; // variable that holds the xy-coordinates of the upper-left corner of the textframe var cutout_rightBottom = phw - 20; // variable that holds the xy-coordinates of the bottom-right corner of the textframe // create textframe var cutout_tf = page.textFrames.add({ geometricBounds: [cutout_topLeft, cutout_topLeft, cutout_rightBottom, cutout_rightBottom], contents: 'a' }); cutout_tf.paragraphs.item(0).properties = { pointSize: 10, justification : Justification.CENTER_ALIGN, } //cutout_tf.paragraphs.item(0).appliedFont = myfont; var cutout_shape = cutout_tf.createOutlines(true); // convert text to outlines var the_shape = cutout_shape[0]; var cutout_bounds = the_shape.geometricBounds; // get the bounds of the first var coutout_top_y = cutout_bounds[0]; var coutout_bottom_y = cutout_bounds[2]; var cutout_height = coutout_bottom_y - coutout_top_y; var cutout_height_new = phw - 20; var cutout_scalefactor = ((100/cutout_height)*cutout_height_new)/100; var cutout_bounds_new = new Array(); for (var n=0; n b.brightness) return 1; return 0; } function compare_customly(a,b) { if (a.brightness > b.brightness) return -1; if (a.brightness < b.brightness) return 1; return 0; }