Why rotating and translating a duplicated layers in a loop tend towards the center of the image?
The code below should duplicate, rotate and translate layers at random positions on the screen each one in a loop with given iterations. Duplicating of layers is executed well, but rotation and translation is giving me very strange results, and that instead of rotating as well as translating randomly it tends to do that towards the center of the image:
doc = app.activeDocument;
function random(min, max) {
const num = Math.floor(Math.random() * (max - min + 1)) + min;
return num;
};
function duplicateCurrentLayer(iter){
for(i=0;i<iter;i++){
doc.activeLayer.duplicate();
doc.activeLayer.translate(random(-256,256),random(-256,256));
doc.activeLayer.rotate(random(20,50),AnchorPosition.MIDDLECENTER);
}
}
doc.suspendHistory("duplicate","duplicateCurrentLayer(30)");Please find the image belo as an example to see what I mean:

The first two duplicates are fine translated and rotated, but the others tend towards the center of the image.
Thanks.
