Skip to content

Instantly share code, notes, and snippets.

@panych
Last active August 29, 2015 14:21
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 panych/4b23b5429d1f04328ca2 to your computer and use it in GitHub Desktop.
Save panych/4b23b5429d1f04328ca2 to your computer and use it in GitHub Desktop.
snapToPixel (Illustrator script)
/*
snapToPixel.jsx
Adobe Illustrator script.
Moves any selected objects to the nearest pixel.
*/
if ( documents.length > 0 ) {
var sourceDoc = activeDocument;
var items = selection;
var i = 0 ;
if ( items.length == 0 ) {
alert( "Select at least one item before running this script.");
} else {
// move items to nearest pixel
for ( i = 0 ; i < items.length; i++ ) {
items[i].left = Math.round( items[i].left );
items[i].top = Math.round( items[i].top );
}
redraw();
}
} else {
alert( "No document provided." );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment