Hello Everyone,
I was hoping to create a JS script to move objects away from common center based upon their current position. I was thinking to use a single selected path item as the center based on its position x/y and width/height. Using this reference point the script would then move away all other path items from this center point based on a desired amount and with uniform increments given their current location from this center. I was thinking cos and sin would be my friend in this case, however they seem to have become my foe instead. ;-)
Does this sound doable? What am I missing, doing wrong, misinterpreting? Below is a non-working attempt, I can't seem to sort things out, perhaps I was close and missed it or maybe I am super way off and its more complex than I thought. However at this point I am confused across my various failed attempts this only being one of them.
Thanks in advance for any assistance and sanity anyone can provide.
// Example failed code, nonworking concept
var docID = app.activeDocument;
var s0 = docID.selection[0];
pID = docID.pathItems;
var xn, yn;
var stepNum = 20;for (var i = 0; i < pID.length; i++) { var p = pID[i]; var dx = ((s0.position[0] + s0.width) / 2 - (p.position[0] + p.width) / 2); var dy = ((s0.position[1] + s0.height) / 2 - (p.position[1] + p.height) / 2); xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum; yn = Math.sin(Number(dy) * Math.PI / 180)+stepNum; var moveMatrix = app.getTranslationMatrix(xn, yn); p.transform(moveMatrix); stepNum+=stepNum;}