﻿/*    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;
	rect = thisLayer.sourceRectAtTime(2);

	switch (n){
	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)
