The coordinate of the center of the node (at (0,0)
) will stay the same. But you can extract the coordinates of the bounding box (which is identical with the output format if you use the standalone
package) and use these coordinates to calculate how far the center of the node is from each edge.
You can use the virtual node current bounding box
and its anchors north east
and south west
in combination with \pgfgetlastxy
to get the coordinates of the current bounding box (you probably only need south west
though):
\path (current bounding box.north east);
\pgfgetlastxy{\boundingboxeast}{\boundingboxnorth}
\path (current bounding box.south west);
\pgfgetlastxy{\boundingboxwest}{\boundingboxsouth}
The following code will print (current bounding box.south west) is at (-77.49pt,-13.25343pt).
to the log:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (c1) at (0,0);
\coordinate (c2) at (-2, 0.2);
\node[circle,inner sep=2pt,draw=none,fill=red] at (c1) {};
\draw[color=blue,bend left=150] (c1) to (c2);
\path (current bounding box.south west);
\pgfgetlastxy{\boundingboxwest}{\boundingboxsouth}
\message{(current bounding box.south west) is at (\boundingboxwest,\boundingboxsouth).}
\end{tikzpicture}
\end{document}
You could create a custom helper macro like this:
\documentclass{standalone}
\usepackage{tikz}
\NewDocumentCommand{\whereiscoordinate}{m}{
\path (current bounding box.south west);
\pgfgetlastxy{\currentboundingboxwest}{\currentboundingboxsouth}
\path #1;
\pgfgetlastxy{\currentcoordinatex}{\currentcoordinatey}
\pgfmathsetmacro{\currentcoordinatedistancex}
{-1*\currentboundingboxwest+\currentcoordinatex}
\pgfmathsetmacro{\currentcoordinatedistancey}
{-1*\currentboundingboxsouth+\currentcoordinatey}
\message{Coordinate #1
is \currentcoordinatedistancex pt from the left and
\currentcoordinatedistancey pt from the bottom
of the current bounding box. ^^J}
}
\begin{document}
\begin{tikzpicture}
\coordinate (c1) at (0,0);
\coordinate (c2) at (-2, 0.2);
\node[circle,inner sep=2pt,draw=none,fill=red] at (c1) {};
\draw[color=blue,bend left=150] (c1) to (c2);
\whereiscoordinate{(0,0)}
% prints to the log:
% Coordinate (0,0) is 77.49pt from the left and 13.25343pt from the bottom
% of the current bounding box.
\whereiscoordinate{(-2,0.2)}
% prints to the log:
% Coordinate (-2,0.2) is 20.58452pt from the left and 18.9439pt from the bottom
% of the current bounding box.
\end{tikzpicture}
\end{document}
(0,0)
. But you can extract the coordinates of the bounding box and use this to calculate how far this coordinate is from each edge. To get the coordinates of the bounding box, you can do something like\path (current bounding box.south east); \pgfgetlastxy{\boundingboxeast}{\boundingboxsouth} \path (current bounding box.north west); \pgfgetlastxy{\boundingboxwest}{\boundingboxnorth}
. Consider providing a compilable minimal working example (MWE) which will make it easier to help you in more detail.\end{tikzpicture}
?