[Espen Jakobsen] “Ah! So dividing the position coordinates by two will put it in the center, thanks a million! :)”
Just to clarify, Dan isn’t dividing any position coordinates by two. If I rewrite this it may make more sense:
L = thisComp.layer("sun");
center = [L.width/2, L.height/2];
L.toComp(center);
The above expression is the same as what Dan gave you, only I’ve created a new variable to hold the layer coordinates we’re providing to toComp().
The function toComp() is expecting a coordinate in layer space, in this case specifically it wants a coordinate in the layer space of the layer L (the “sun” layer).
In your original code you had:
thisComp.layer("sun").toComp([0,0,0]);
Which would return the location of the point [0,0,0] on the layer (the upper left corner) in composition coordinates. What Dan did is instead gave the toComp() function a coordinate representing the center of the layer.
In order to find the center of the layer he simply divided the width and height of the layer in pixels by 2:
[L.width/2, L.height/2]
Does that make sense? If, instead, he had written:
[L.width, L.height]
Then the flare would have followed the lower right corner of the “sun” layer. What we’re doing here is taking a point in layer space (like a layer’s anchor point) and converting it to composition space (like a layer’s position coordinates).
Darby Edelen