4

I have a TikZ picture

\begin{tikzpicture}[scale=0.5]
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm);
\end{tikzpicture}

which makes a small ball.

Is it possible to reuse this shape in another tikz picture?

I have another tikz picture in which I use

\draw[fill=yellow!30, fill opacity=0.5,text opacity=1] (B) circle (0.7cm) node[right] {$A$};

Instead of circle I want my small custom ball. How is that possible?

Jamgreen
  • 3,687

1 Answers1

0

Unrecommended way

There are several ways, this one puts tikzpicture environment to another tikzpicture environment with help of a \node.

%! *latex mal-tikz-tikz.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{tikz}
\begin{document}
\def\malpic{%
\begin{tikzpicture}[scale=0.5]
  \draw (-1,0) arc (180:360:1cm and 0.5cm);
  \draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
  \draw (0,1) arc (90:270:0.5cm and 1cm);
  \draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
  \draw (0,0) circle (1cm);
  \shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm);
  \end{tikzpicture}%
  }%End of \malpic...
\begin{tikzpicture}
\coordinate (B) at (0,0);
\node[fill=yellow!30, fill opacity=0.5,text opacity=1] at (B) {\malpic} node[right] {$A$};
\end{tikzpicture}
\end{document}

mwe

Malipivo
  • 13,287