Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Forked from vladocar/NumberGuidesGrid.js
Created July 30, 2014 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arahnoid/f3929e7714f0ba303370 to your computer and use it in GitHub Desktop.
Save Arahnoid/f3929e7714f0ba303370 to your computer and use it in GitHub Desktop.
var doc = app.activeDocument;
var guides = app.activeDocument.guides;
var w = doc.width;
var h = doc.height;
function MakeGuidesGrid(numVerticalGuides, gutterVertical, numHorisontalGuides, gutterHorisontal) {
if (numHorisontalGuides !== 0) {
var j = h / numHorisontalGuides;
for (var i = 0; i < numHorisontalGuides; i++) {
guides.add(Direction.HORIZONTAL, j * i);
guides.add(Direction.HORIZONTAL, j * i + gutterHorisontal);
}
}
if (numVerticalGuides !== 0) {
var z = w / numVerticalGuides;
for (var i = 0; i < numVerticalGuides; i++) {
guides.add(Direction.VERTICAL, z * i);
guides.add(Direction.VERTICAL, z * i + gutterVertical);
}
}
}
MakeGuidesGrid(parseInt(prompt("Insert the number of Vertical guides", 40)), parseInt(prompt("Insert the Vertical gutter size", 10)), parseInt(prompt("Insert the number of Horisontal guides", 40)), parseInt(prompt("Insert the Vertical gutter size", 10)));
//MakeGuidesGrid(40,10,40,10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment