Question
Make a script to position anchor point
Hi 🙂
I want to make a script to move the anchor point of a selected solid to the top left. how can I do that?
I have this function to center it but dont know how to convert it to the top left
function centerAnchorPoint( layer ){
var comp = layer.containingComp;
var curTime = comp.time;
var layerAnchor = layer.anchorPoint.value;
/* find center by bounding box of the layer */
var x = layer.sourceRectAtTime(curTime, false).width/2;
var y = layer.sourceRectAtTime(curTime, false).height/2;
var xAdd = (x-layerAnchor[0]) * (layer.scale.value[0]/100);
var yAdd = (y-layerAnchor[1]) * (layer.scale.value[1]/100);
/* set new anchor point*/
layer.anchorPoint.setValue([ x, y ]);
var layerPosition = layer.position.value;
/* fix position with adjustments */
layer.position.setValue([ layerPosition[0] + xAdd, layerPosition[1] + yAdd, layerPosition[2] ]);
};