Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  21] [ 7]  / answers: 1 / hits: 18957  / 12 Years ago, tue, august 21, 2012, 12:00:00

I have an active ArtLayer referenced by the variable NewLayer that I want to move to the absolute position x,y in the canvas.



I have been googling for a couple of hours now without any results. Can some one please give an example?



// Thanks.


More From » photoshop

 Answers
36

After some more API reading and searching I came to the conclusion that it is only possible to move a layer with delta move.



I wrote this little function to position a layer at an absolute position. Hope this is helpful to the next reader with the same question...



//******************************************
// MOVE LAYER TO
// Author: Max Kielland
//
// Moves layer fLayer to the absolute
// position fX,fY. The unit of fX and fY are
// the same as the ruler setting.

function MoveLayerTo(fLayer,fX,fY) {

var Position = fLayer.bounds;
Position[0] = fX - Position[0];
Position[1] = fY - Position[1];

fLayer.translate(-Position[0],-Position[1]);
}

[#83494] Tuesday, August 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
markusdamienn

Total Points: 167
Total Questions: 119
Total Answers: 93

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;