/* * Author: Andrew Ingram * Email: andy@andrewingram.net */ $.localize = true; if(app.name.indexOf("Photoshop") >= 0) { 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 2', [100,100,440,290]); dlg.okButton = dlg.add('button', [120,160,220,180], 'OK'); dlg.cancelButton = dlg.add('button', [230,160,330,180], 'Cancel'); dlg.optionsPanel = dlg.add('panel', [10,10,240,150], 'Variables'); dlg.unitsPanel = dlg.add('panel', [250,10,330,150], 'Units'); dlg.optionsPanel.labelColumnWidth = dlg.optionsPanel.add('statictext', [10,23,111,40], 'Column width'); dlg.optionsPanel.labelGutterWidth = dlg.optionsPanel.add('statictext', [10,48,111,65], 'Gutter width'); dlg.optionsPanel.labelColumnWidth = dlg.optionsPanel.add('statictext', [10,73,111,90], 'Number of columns'); dlg.optionsPanel.labelSubdivisions = dlg.optionsPanel.add('statictext', [10,98,111,115], 'Column Divisions'); dlg.optionsPanel.inputColumnWidth = dlg.optionsPanel.add('edittext', [120,20,216,40], '100'); dlg.optionsPanel.inputGutterWidth = dlg.optionsPanel.add('edittext', [120,45,216,65], '10'); dlg.optionsPanel.inputCount = dlg.optionsPanel.add('edittext', [120,70,216,90], '4'); dlg.optionsPanel.inputSubdivisions = dlg.optionsPanel.add('edittext', [120,95,216,115], '1'); //dlg.optionsPanel.selectOuterGutters = dlg.optionsPanel.add('checkbox', [10,100,216,131] , 'Include outer gutters'); dlg.unitsPanel.selectPixels = dlg.unitsPanel.add('radiobutton', [10,20,111,41], 'pixels'); dlg.unitsPanel.selectMm = dlg.unitsPanel.add('radiobutton', [10,40,111,61], 'mm'); dlg.unitsPanel.selectCm = dlg.unitsPanel.add('radiobutton', [10,60,111,81], 'cm'); dlg.unitsPanel.selectInches = dlg.unitsPanel.add('radiobutton', [10,80,111,101], 'inches'); dlg.unitsPanel.selectPixels.value = true; /* * okButton Event, performs calculations, generates document and guides, closes dialog. */ dlg.okButton.onClick = function okClick() { var pixelsPerInch = 72; var inchScale = pixelsPerInch; var cmScale = inchScale / 2.54; var mmScale = cmScale / 10; var phi = 1.61803399; var columnWidth = dlg.optionsPanel.inputColumnWidth.text; var gutterWidth = dlg.optionsPanel.inputGutterWidth.text; var count = dlg.optionsPanel.inputCount.text; var subdivisions = dlg.optionsPanel.inputSubdivisions.text - 1; //var selectOuterGutters = dlg.optionsPanel.selectOuterGutters.value;1.61803399 var rowHeight = columnWidth / phi; var gutterHeight = gutterWidth; var width = (columnWidth*count)+(gutterWidth*(count-1)); var height = (rowHeight*count)+(gutterHeight*(count-1)); width = width + (gutterWidth * 2); height = height + (gutterHeight * 2); //width=parseInt(width); //height=parseInt(height); var numberOfGuides=((count*2)-2) + (count*subdivisions); var numberOfRowGuides=(count*2)-2; numberOfGuides=numberOfGuides + 2; numberOfRowGuides=numberOfRowGuides + 2; var guides = new Array(); var rowGuides = new Array(); rowGuides[0]=gutterHeight; rowGuides[1]=rowHeight; guides[0]=gutterWidth; for(i=0;i