npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

psd-guides

v1.0.1

Published

Draw photoshop-like guides

Downloads

9

Readme

psd-guides

npm-image bower-image

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,                 // [DOMElement]
  canvasWidth : 0,                        // [Integer] (pixels)
  alignment : "center",                   // [String] "center"|"left"|"right"
  backColor : "rgba(132, 170, 234, .25)", // [String] Any valid color format
  lineColor : "rgba(73, 141, 255, 1)",    // [String] Any valid color format
  horizontalGuides : [],                  // [Array]
  verticalGuides : [],                    // [Array]
  zindex : 9999                           // [Number]
}

API

activate

/**
 * Display the guides.
 * @property activate <public> [Function]
 * @return this [PSDGuides]
 */

var psd = new PSDGuides({
	canvasWidth : 1000,
	horizontalGuides : [20, "355 * 2", 250],
	verticalGuides : [50, "100 * 2", "250 * 2", "50 * 3"]
});

psd.activate();

deactivate

/**
 * Hide the guides.
 * @property deactivate <public> [Function]
 * @return this [PSDGuides]
 */

psd.deactivate();

update

/**
 * Update the width and height of psd-guides container,
 * remove and create the guides using the guides array references.
 * @property update <public> [Function]
 * @return this [PSDGuides]
 */

psd.update();

destroy

/**
 * Clean all references to other objects and remove DOMElements.
 * @property destroy <public> [Function]
 * @return null
 */

psd.destroy();
// => null

# Removing guides

When guides are removed, you need to call the update or activate method to reflect the changes.

removeHorizontalGuides

/**
 * Clear the horizontal guides array reference.
 * @property removeHorizontalGuides <public> [Function]
 * @return this [PSDGuides]
 */

psd.removeHorizontalGuides();
// console.log( psd.getHorizontalGuides() );
// => []
// console.log( psd.getVerticalGuides() );
// => [50, 100, 100, 250, 250, 50, 50, 50]

removeVerticalGuides

/**
 * Clear the vertical guides array reference.
 * @property removeVerticalGuides <public> [Function]
 * @return this [PSDGuides]
 */

psd.removeVerticalGuides();
// console.log( psd.getVerticalGuides() );
// => []

removeGuides

/**
 * Clear both horizontal and vertical array references.
 * @property removeGuides <public> [Function]
 * @return this [PSDGuides]
 */

psd.removeGuides().update();

# Adding guides

When adding guides, you need to call the update or activate method after to reflect the changes.

addHorizontalGuides

/**
 * Add guides to the _horizontalGuides Array holder.
 * @property addHorizontalGuides <public> [Function]
 * @argument guides <required> [Array]
 * @return this [PSDGuides]
 */

psd.addHorizontalGuides([20, "355 * 2", 250]).update();
// console.log( psd.getHorizontalGuides() );
// => [20, 355, 355, 250]

addVericalGuides

/**
 * Add guides to the _verticalGuides Array holder.
 * @property addVerticalGuides <public> [Function]
 * @argument guides <required> [Array]
 * @return this [PSDGuides]
 */

psd.addVerticalGuides([50, "100 * 2", "250 * 2", "50 * 3"]).update();
// console.log( psd.getVerticalGuides() );
// => [50, 100, 100, 250, 250, 50, 50, 50]

# Getting the guides

Get current saved guides.

getHorizontalGuides

/**
 * Return the current saved horizontal guides.
 * @property getHorizontalGuides <public> [Function]
 * @return this._horizontalGuides [Array]
 */

psd.getHorizontalGuides();
// => [20, 355, 355, 250]

getVerticalGuides

/**
 * Return the current saved vertical guides.
 * @property getVerticalGuides <public> [Function]
 * @return this._verticalGuides [Array]
 */

psd.getVerticalGuides();
// => [50, 100, 100, 250, 250, 50, 50, 50]

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.