psd-guides

http://noeldelgado.github.io/psd-guides/
psd-guides is a simple script to draw photoshop-like guides.
Can be useful during slicing phase to accomplish pixel-perfect web layouts.
Installation
NPM
npm install psd-guides --save
BOWER
bower install psd-guides --save
Usage
new PSDGuides({
canvasWidth : 1000,
horizontalGuides : [20, "355 * 2", 250, 20],
vericalGuides : [50, "100 * 2", "250 * 2", "50 * 3"]
}).activate();
Tip: While defining your guides, if you have similar values that needs to be repeated several times, instead of writing them all you can use the * character followed by the number you want it to be repeated, for instance: vericalGuides : [10, 10, 10, 10, 10, 20, 30, 20, 30, 20, 30] can be written as verticalGuides : ["10 * 5", "(20, 30) * 3"]
Defaults
{
canvas : document.body,
canvasWidth : 0,
alignment : "center",
backColor : "rgba(132, 170, 234, .25)",
lineColor : "rgba(73, 141, 255, 1)",
horizontalGuides : [],
verticalGuides : [],
zindex : 9999
}
API
activate
var psd = new PSDGuides({
canvasWidth : 1000,
horizontalGuides : [20, "355 * 2", 250],
verticalGuides : [50, "100 * 2", "250 * 2", "50 * 3"]
});
psd.activate();
deactivate
psd.deactivate();
update
psd.update();
destroy
psd.destroy();
# Removing guides
When guides are removed, you need to call the update or activate method to reflect the changes.
removeHorizontalGuides
psd.removeHorizontalGuides();
removeVerticalGuides
psd.removeVerticalGuides();
removeGuides
psd.removeGuides().update();
# Adding guides
When adding guides, you need to call the update or activate method after to reflect the changes.
addHorizontalGuides
psd.addHorizontalGuides([20, "355 * 2", 250]).update();
addVericalGuides
psd.addVerticalGuides([50, "100 * 2", "250 * 2", "50 * 3"]).update();
# Getting the guides
Get current saved guides.
getHorizontalGuides
psd.getHorizontalGuides();
getVerticalGuides
psd.getVerticalGuides();
Examples (960 Grid System)
Applying 960 grid system
12-column grid
new PSDGuides({
canvasWidth : 960,
horizontalGuides : ["(10, 60, 10) * 12"]
}).activate()
16-column grid
new PSDGuides({
canvasWidth : 960,
horizontalGuides : ["(10, 40, 10) * 16"]
}).activate();
24-column grid
new PSDGuides({
canvasWidth : 960,
horizontalGuides : ["(10, 20, 10) * 24"]
}).activate()
There are more examples inside the examples folder.