Created
October 7, 2012 12:46
-
-
Save coerv/3848298 to your computer and use it in GitHub Desktop.
Corvins Projektwochenzeug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** 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 | |
for(var i=0; i<5; i++){ | |
var my_color = doc.colors.add(); | |
var R = Math.random() * 255; | |
var G = Math.random() * 255; | |
var B = Math.random() * 10; | |
my_color.name = "my new color"+ i; | |
my_color.model = ColorModel.PROCESS; | |
my_color.space = ColorSpace.RGB; | |
my_color.colorValue = [R,G,B]; | |
// determine the brightness of the color | |
my_color_brightness = R + G + B; | |
colors1.push(my_color); | |
} | |
alert(colors1); | |
/*** create textframe ***/ | |
var topLeft = 0 + 10; // variable that holds the xy-coordinates of the upper-left corner of the textframe | |
var rightBottom = phw - 10; // variable that holds the xy-coordinates of the bottom-right corner of the textframe | |
// format text | |
var myfont = app.fonts.item("Delicious"+"\t"+"BoldItalic"); | |
// create textframe | |
var tf = page.textFrames.add({ | |
geometricBounds: [topLeft, topLeft, rightBottom, rightBottom], | |
contents: TextFrameContents.PLACEHOLDER_TEXT | |
}); | |
var single_char = tf.characters.everyItem(); // get the single character | |
single_char.appliedFont = myfont; // you have to apply the font to a character or line or paragraph | |
//alert(myfont.name); // this should work | |
//page.textFrames.item(0).appliedFont = myfont; // a textFrame has no appliedFont. A Character does |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment