# Tikz shape as node

I had created some picture which I plan to use it in different places of the coordinate plane. But I made it in a form of TeX macro \cone{...}.

How can I create such picture in a form of tikz \node[cone]?

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\cone(#1){
\draw (#1) +(135:0.5) -- +(-45:0.5);
\draw (#1) +(45:0.5) -- +(-135:0.5);
\fill (#1) circle (0.03);
\draw let \p1=(#1) in (\x1,{\y1+.35cm}) ellipse (0.352 and 0.05);
\draw let \p1=(#1) in (\x1,{\y1-0.35cm}) ellipse (0.352 and 0.05);
}

\coordinate (A) at (0,0);
\coordinate (B) at (1,1);

\cone(A)
\cone(B)

\end{tikzpicture}
\end{document}

• your cones remain me on "small picture" \pic. it can be used as \pic at (x,y) {cone}. Oct 11 '17 at 23:16
• @Zarko Can you write your answer? It, seems, also good solution. Oct 11 '17 at 23:31
• Oct 18 '17 at 7:06

above images is drawn with \pic

\documentclass[tikz, border=1cm]{standalone}

\begin{document}
\begin{tikzpicture}[
cone/.pic = {\draw (-0.5,-0.5) -- ++ (1, 1);
\draw (-0.5, 0.5) -- ++ (1,-1);
\fill (0,0) circle (0.03);
\draw (0, 0.5) ellipse (0.5 and 0.05);
\draw (0,-0.5) ellipse (0.5 and 0.05);
}
]
\pic at (0,0) {cone};
\pic at (2,1) {cone};
\end{tikzpicture}
\end{document}


since context of use "cone" is unknown, i didn't define any anchor of cones.

in case when you like to draw lines between cones, than you need to define anchors of cones:

\documentclass[tikz, border=1cm]{standalone}

\begin{document}
\begin{tikzpicture}[
cone/.pic = {\draw (-0.5, 0.5) coordinate (-nw) -- ++ (1,-1) coordinate (-se);
\draw (-0.5,-0.5) coordinate (-sw) -- ++ (1, 1) coordinate (-ne);
\fill (0,0)  coordinate (-center) circle (0.03);
\draw (0, 0.5) ellipse (0.5 and 0.05);
\draw (0,-0.5) ellipse (0.5 and 0.05);
\coordinate (-top)     at (0, 0.55);
\coordinate (-north)   at (0, 0.5);
\coordinate (-south)   at (0,-0.5);
\coordinate (-bottom)  at (0,-0.55);
}
]
\pic (A) at (0,0) {cone};
\pic (B) at (2,1) {cone};
\draw[red] (A-center) -- (B-bottom);
\draw[blue] (A-north) -- + (0,2) -| (B-north);
\draw[green] (A-ne) |- (B-nw);
\pic[rotate=90] (B) at (4,0) {cone};
\end{tikzpicture}
\end{document}


• Context of cone is "light cone" in theory of special relativity Oct 11 '17 at 23:48
• if you will not draw lines between cones, anchors aren't needed, otherwise you should defined it. it is simple to do. Oct 11 '17 at 23:51
• I plan to draw such lines between cones Oct 11 '17 at 23:53
• @sergiokapone, to answer i add addendum where i define cone with nine anchors and show some possibilities for contest them with lines. Oct 12 '17 at 0:11