forked from johnwun/js4ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixelAlign.jsx
36 lines (29 loc) · 959 Bytes
/
pixelAlign.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/////////////////////////////////////////////////////////////////
//Pixel Align v.1.1 -- CS, CS5
//>=--------------------------------------
// A super simple script that snaps selected objects to their nearest pixel values.
// Used for aligning artwork for exporting as raster art.
// Note: Can have issues with stroked objects.
//
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( [email protected] ) www.wundes.com
//copyright full text here: http://www.wundes.com/js4ai/copyright.txt
//////////////////////////////////////////////////////////////////
var doc = activeDocument;
var sel = doc.selection;
var selLen = sel.length;
while(selLen--)
{
fidget(sel[selLen]);
}
function fidget(item)
{
item.height = pixAlign(item.height);
item.width = pixAlign(item.width);
item.top = pixAlign(item.top);
item.left = pixAlign(item.left);
}
function pixAlign(n)
{
return Math.round(n)
}