function centerToPos(piece, to){
    var x, y;
    if(piece.type % 2){ // if odd
       if(piece.orientation === 1){
            x = to[0] - Math.floor(piece.type / 2);
            y = to[1];
        } else{
            x = to[0];
            y = to[1] - Math.floor(piece.type / 2);
        }
        
    } else{
        if(piece.orientation === 1){
            x = to[0] - piece.type / 2 + 1;
            y = to[1];
        } else{
            x = to[0];
            y = to[1] - piece.type / 2 + 1;
        }
    }
    return [x, y];
}
/**
 * Given a piece and coordinates of the center of the piece(to),
   returns the left hand coordinate of the piece, corresponding to the pos attribute.
 * @param {Object} piece Piece whose left hand coordinates it is going to return 
 * @param {Array} to The center coordinates of the piece chosen.
 * return {Array} [x, y] piece pos.
 */
Given a piece and coordinates of the center of the piece(to),
returns the left hand coordinate of the piece, corresponding to the pos attribute.
@param {Object} piece Piece whose left hand coordinates it is going to return
@param {Array} to The center coordinates of the piece chosen.
return {Array} [x, y] piece pos.
Given a piece and coordinates of the center of the piece ( to ) returns the left hand coordinate of the piece corresponding to the pos attribute . @param { Object } piece Piece whose left hand coordinates it is going to return @param { Array } to The center coordinates of the piece chosen . return { Array } [ x y ] piece pos .
function centerToPos(piece, to){
    var x, y;
    if(piece.type % 2){ 
       if(piece.orientation === 1){
            x = to[0] - Math.floor(piece.type / 2);
            y = to[1];
        } else{
            x = to[0];
            y = to[1] - Math.floor(piece.type / 2);
        }
    } else{
        if(piece.orientation === 1){
            x = to[0] - piece.type / 2 + 1;
            y = to[1];
        } else{
            x = to[0];
            y = to[1] - piece.type / 2 + 1;
        }
    }
    return [x, y];
}
function centerToPos ( piece , to ) { var x , y ; if ( piece . type % 2 ) { if ( piece . orientation === 1 ) { x = to [ 0 ] - Math . floor ( piece . type / 2 ) ; y = to [ 1 ] ; } else { x = to [ 0 ] ; y = to [ 1 ] - Math . floor ( piece . type / 2 ) ; } } else { if ( piece . orientation === 1 ) { x = to [ 0 ] - piece . type / 2 + 1 ; y = to [ 1 ] ; } else { x = to [ 0 ] ; y = to [ 1 ] - piece . type / 2 + 1 ; } } return [ x , y ] ; }
Given a piece and coordinates of the center of the piece(to),
returns the left hand coordinate of the piece, corresponding to the pos attribute.
Given a piece and coordinates of the center of the piece ( to ) returns the left hand coordinate of the piece corresponding to the pos attribute .
// if odd