GUI version
#target illustrator
buildGUI();
function buildGUI(){
var resource =
"dialog { text:'jooScatter',\
properties:{ closeButton:true, maximizeButton:false,\
minimizeButton:false, resizeable:false },\
orientation:'row', spacing:2, margins:5,\
alignChildren:['left','fill'],\
g: Group {\
alignChildren:['left','fill'],\
orientation:'column', spacing:20,margins:5,\
p1: Panel {\
text: 'Scatter Offsets:',\
g1: Group {\
orientation:'column',\
x: Group {\
st: StaticText { text:'x width:'},\
f: EditText {text:'100', characters:20}\
},\
y: Group {st2 : StaticText{ text:'y width:'},\
f: EditText { text:'100' , characters:20 },\
},\
},\
},\
g2: Group { alignment: 'right', orientation:'row',\
apply: Button { text: 'Apply'},\
cancel: Button { text:'Cancel'},\
}\
}\
}"
var win = new Window (resource);
var cancel = function() {
win.close(0);
}
var apply = function() {
scatter_box(activeDocument.selection,
eval(win.g.p1.g1.x.f.text),
eval(win.g.p1.g1.y.f.text)
);
redraw();
}
win.g.g2.apply.onClick = apply;
win.g.g2.cancel.onClick = cancel;
win.show();
}
function scatter_box(items, xoffset, yoffset){
for(var i=0;i<items.length;i++){
var oldpos = items[i].position;
items[i].position= [oldpos[0]+Math.random()*xoffset-xoffset/2,
oldpos[1]+Math.random()*yoffset-yoffset/2];
}
}