/* * GridMaker automatically generates a new photoshop document and guides based * on vertical and horizontal grid specifications and upper limits on document * size. Does not currently do any error-handling so make sure all your inputs * are correct. * * Author: Andrew Ingram * Email: andy@andrewingram.net */ app.bringToFront(); $.localize = true; try { mainDialog(); } catch( e ) { } function mainDialog() { /* * Create the dialog and initial values. Initial configuration * produces a document with a 64x64 grid with a 3px gutter within * a maximum size of 1024x768 */ var dlg = new Window('dialog', 'GridMaker', [100,100,365,270]); dlg.vPanel = dlg.add('panel', [5,5,130,130], 'Vertical Guides'); dlg.vPanel.configLabel = dlg.vPanel.add('statictext', [5,5,115,27], 'Configuration:'); dlg.vPanel.config = dlg.vPanel.add('edittext', [5,25,115,46], '3,64'); dlg.vPanel.maxWidthLabel = dlg.vPanel.add('statictext', [5,47,115,69], 'Maximum Width:'); dlg.vPanel.maxWidth = dlg.vPanel.add('edittext', [5,67,115,88], '1024'); dlg.vPanel.checkBox = dlg.vPanel.add('checkbox', [5,95,115,110], 'Generate Guides?'); dlg.vPanel.checkBox.value=true; dlg.hPanel = dlg.add('panel', [135,5,260,130], 'Horizontal Guides'); dlg.hPanel.configLabel = dlg.hPanel.add('statictext', [5,5,115,27], 'Configuration:'); dlg.hPanel.config = dlg.hPanel.add('edittext', [5,25,115,46], '3,64'); dlg.hPanel.maxHeightLabel = dlg.hPanel.add('statictext', [5,47,115,69], 'Maximum Height:'); dlg.hPanel.maxHeight = dlg.hPanel.add('edittext', [5,67,115,88], '768'); dlg.hPanel.checkBox = dlg.hPanel.add('checkbox', [5,95,115,110], 'Generate Guides?'); dlg.hPanel.checkBox.value=true; dlg.okButton = dlg.add('button', [50,140,150,160], 'OK'); dlg.cancelButton = dlg.add('button', [160,140,260,160], 'Cancel'); /* * okButton Event, performs calculations, generates document and guides, closes dialog. */ dlg.okButton.onClick = function okClick() { /* * Split the config string using comma as seperator */ var vArray=dlg.vPanel.config.text.split(","); var vSum = 0; /* * Calculate the sum of values in the config string */ for (i=0;i