From 1747441b6da1b06f0ca371c7541b50874fb6399b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Wed, 5 Dec 2018 14:50:39 -0800 Subject: [PATCH] Expression for centering the anchor point on text layers. --- jsx/EXP_centerTextLayerAnchor.jsx | 1 + 1 file changed, 1 insertion(+) create mode 100644 jsx/EXP_centerTextLayerAnchor.jsx diff --git a/jsx/EXP_centerTextLayerAnchor.jsx b/jsx/EXP_centerTextLayerAnchor.jsx new file mode 100644 index 0000000..353c059 --- /dev/null +++ b/jsx/EXP_centerTextLayerAnchor.jsx @@ -0,0 +1 @@ +/* 0 center | 1 right | 2 left | 3 top | 4 bottom | 5 top right | 6 top left | 7 bottom right | 8 bottom left */ function centerTextLayerAnchor( n ){ rect = thisLayer.sourceRectAtTime(); t = rect.top; h = rect.height x = rect.left + (rect.width/2); y = (t-( t-h)+(t*2))/2; switch (n){ rect = thisLayer.sourceRectAtTime(2); case 0 : offset = [0,0]; break; case 1 : offset = [ rect.width/2 , 0 , 0]; break; case 2 : offset = [ -rect.width/2 , 0 , 0]; break; case 3 : offset = [0 , -rect.height/2 , 0]; break; case 4 : offset = [0 , rect.height/2 , 0]; break; case 5 : offset = [ rect.width/2 , -rect.height/2 , 0]; break; case 6 : offset = [ -rect.width/2 , -rect.height/2 , 0]; break; case 7 : offset = [ rect.width/2 , rect.height/2 , 0]; break; case 8 : offset = [ -rect.width/2 , rect.height/2 , 0]; break; } newAnchor = [ x , y ] + offset; return newAnchor } centerTextLayerAnchor(0) \ No newline at end of file