Last active
August 29, 2015 14:21
-
-
Save panych/4b23b5429d1f04328ca2 to your computer and use it in GitHub Desktop.
snapToPixel (Illustrator script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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