Got InDesign to auto-run a script on startup. I was worried about this, but it turns out it’s quite easy to do.
Getting Draftbot to auto-run for exhibition
April 21st, 2010The magic search term is “Computational Aesthetics”
February 27th, 2010Optimizing Photo Composition
February 22nd, 2010This is completely inspiring, but also a little discouraging.
Ligang Liu, Renjie Chen at Zhejiang University and Lior Wolf, Daniel Cohen-Or at Tel-Aviv University seem to have done exactly what I am seeking to do, only with photos not, page layout.
The most amazing thing to me was the explanation of calculating the visual mass. I’d been looking for a formula to do just that and here they summarized one. Now all I have to do is code it.
Adding Long Text
February 12th, 2010On a whim, I wondered what Draftbot would do if I put longer text into the folder of content. The text is the content of A list Apart article that is the first google result for Article Text. Well it seems when placing text with only x and y coordinates, it takes the y coordinate but fills the space between the margins.

I have to say, I find some of these to be quite good (look at the tension filled whitespace in the upper right draft), and this is with almost no logic, just random number generation.
Building a User Interface
February 12th, 2010
It’s a start.
Placing Files
February 12th, 2010In anticipation of User Testing, I’ve begun implementing the code to place objects on pages. The interface now (pre-testing) involves the user choosing a folder of files to be placed.

Headline, by the way, says “Dewey Defeates Truman.”
So after some trouble accessing the page object I began with simple test code:
loop through the files in the folder
pick a random number between margin left & margin right
place the file at this coordinate at 100% size
Here is a pitfall I ran into: myPage.marginPreferences.left is the offset of the margin from the page. myPage.marginPreferences.right is the same. Therefore finding a random number between these two values will produce the exact same number each time because both vaules are the same. You have to take pageWidth and subtract the right margin to get the actual value. I’m happy to say this only tripped me up once.

Fonts. How to make the best of what there is?
February 3rd, 2010One of the things I would like Draftbot to do is to come up with different font combinations. A sans plus a serif, a display and a body. I would also like these choices to be determined at runtime, not just a choice of a set of predetermined matches.
Picking a pair of fonts isn’t as difficult as this: how do I determine the best selection of fonts based on the selection available on the users computer? Do I poll the font selection at the beginning for the matches against a common list? Do I literally pick fonts at random? (This would be a good starting point if I could then determine the characteristics of the font. Or do I just restrict myself to known fonts installed with InDesign.
Result of a long days work
January 31st, 2010I told Draftbot to create 9 different versions and to tile them. I believe this is going to be the default way it runs, with a user configurable number of drafts.

Solving the Margin Problem
January 31st, 2010One of my goals with Draftbot is to implement quite a few design theorems in a modular sense, allowing the rules of different design ethos to merge, the way a human designer might do.
One of the modules I’m working on is Jan Tschichold’s rules of margin ratios, which are as follows:
Top: 3x
Outside: 4x
Inside: 2x
Bottom: 6x
Wonderfully easy to implement, except—what is x? Or, rather, how do we generate an x value that would be consistent with what Tschichold would agree with. (While I have no problem mixing and matching design ideas, I’d rather stay as true to the designer’s concepts when implementing them).
As of now, x is just a random percentage of the page (within a range of values), but I’m going to look into this more.
Random Number Resistance
January 31st, 2010While sitting down to work this weekend, I immediately stumbled on an issue that gave me lots of problems last semester: Random Numbers. (Here is where I hang my head in shame).
But I shouldn’t feel ashamed. Random numbers in Javascript are much different than in any of the other languages I’ve learned. To add to that, there was a typo in the code I was using as an example. But let’s start at the beginning of my troubles.
The InDesign Scripting Manual (written by the wonderful Olav Kvern) has this block of code.
//This function gets a random number in the range myStart to myEnd.function myGetRandom(myStart, myEnd, myInteger){var myRandom;var myRange = myEnd - myStart;if(myInteger == true){myRandom = myStart = Math.round(Math.random());}else{myRandom = myStart + Math.floor(Math.random()*myRange);return myRandom;}
Note the line in bold. Note the two equals signs, the second one should be a +. The good news is I discovered this rather quickly. The bad news is, changing this does not make it work, at least not to my satisfaction (0 every time does not a random number make).
After some more googling, I discovered the ever-so-aptly-titled Make JavaScript Math.random() useful page and Generating a random number in JavaScript both of which, helped me get my random numbers under control.