Jan 22
JSFL – Set selected objects on a whole pixel in CS3
I haven’t posted in a while. This is a very simple yet effective JSFL I wrote for a coworker. He needed an easy way to set all the objects he had selected on stage to a whole pixel. Sometimes vectors get blurry if they land on a fraction of a pixel and clients can be quick to point this out. It would suck to do this manually if you had any number larger than 12. Imagine if you had 200 objects onstage and everyone was potentially not on a whole pixel. The world would be doomed without this.
// An array of objects that are selected.
var objects = fl.getDocumentDOM().selection
// Loop thru the objects and set their X and Y coordinates to a round number.
for(var i = 0; i < objects.length; i++){
objects[i].x = Math.round(objects[i].x)
objects[i].y = Math.round(objects[i].y)
}
Thats it. Stick the above code in a JSFL file, select some objects and run it.
SOURCE FILE
No Comments
Leave a comment