3

Am not acquainted yet with 3D diagrams in TikZ and I would like to draw something like the picture attached. Does anybody have any helpful hints?

Onion layers structure of a star

3
12

OK, I'll give it a try in 2D, just to let you start.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document}
    \pagecolor{black}
    
    \definecolor{col1}{RGB}{255,255,153}
    \definecolor{col2}{RGB}{153,51,0}
    \definecolor{col3}{RGB}{209,209,224}
    \definecolor{col4}{RGB}{0,230,115}
    \definecolor{col5}{RGB}{204,0,204}
    \definecolor{col6}{RGB}{255,204,204}
    \definecolor{col7}{RGB}{0,153,254}
    \definecolor{col8}{RGB}{255,80,80}
    
    \begin{tikzpicture}
        \coordinate (C) at (0,0);
        
        \fill[outer color=black,inner color=col1] (C) circle (7 cm);
        \fill[ball color=col1,shading=ball] (C) circle (5 cm);
        \begin{scope}
            \clip (0,-5) rectangle (5,5);
            \foreach \r [count=\i from 1] in {5,4.8,4.6,3,2.5,2.2,1.8,1.6}
                {
                \fill[outer color=col\i,inner color=col\i!70!black] (C) circle (\r cm);
                }
        \end{scope}
        
        \begin{scope}
            \clip (0,-5) rectangle (-5,5);
            \foreach \r [count=\i from 1] in {5,4.8,4.6,3,2.5,2.2,1.8,1.6}
                {
                \filldraw[col\i!70!black] (C) ellipse (0.3*\r cm and \r cm);
                }
        \end{scope}
        
        \begin{scope}
            \clip (90:1.6) arc (90:270:0.3*1.6 cm and 1.6 cm) arc (-90:90:1.6);
            \filldraw[ball color=col8,shading=ball] (C) circle (1.6 cm);
        \end{scope}
    \end{tikzpicture}
\end{document}

look into this star

EDIT: I edited my script to eliminate redundancies and inappropriate class declaration, and above all, to let you define once and for all the slices radii. I tried to add some shading into each slice but it's not working yet (apart from writing each slice in an individual code line, which I find disappointing). I'll let you know later if I find a way to do that correctly.

\documentclass[tikz,border=10pt]{standalone}

\begin{document}
    \pagecolor{black}
    
    \definecolor{col1}{RGB}{255,255,153}
    \definecolor{col2}{RGB}{153,51,0}
    \definecolor{col3}{RGB}{209,209,224}
    \definecolor{col4}{RGB}{0,230,115}
    \definecolor{col5}{RGB}{204,0,204}
    \definecolor{col6}{RGB}{255,204,204}
    \definecolor{col7}{RGB}{0,153,254}
    \definecolor{col8}{RGB}{255,102,0}
    
    \begin{tikzpicture}
        \coordinate (C) at (0,0);
        
        \def\a{5}   \def\b{4.8}  \def\c{4.6} \def\d{3}
        \def\e{2.2} \def\f{1.8}  \def\g{1}   \def\h{0.8}
        
        \fill[outer color=black,inner color=col1] (C) circle (6.5 cm);
        \fill[ball color=col1,shading=ball] (C) circle (5 cm);

        \begin{scope}
            \clip (0,-5) rectangle (5,5);
            \foreach \r [count=\i] in {\a,\b,\c,\d,\e,\f,\g,\h}
                {
                \fill[outer color=col\i,inner color=col\i!70!black] (C) circle (\r cm);
                }
        \end{scope}
        
        \begin{scope}
            \clip (0,-5) rectangle (-5,5);
            \foreach \r [count=\i] in {\a,\b,\c,\d,\e,\f,\g,\h}
                {
                \fill[col\i!70!black] (C) ellipse (0.3*\r cm and \r cm);
                }
        \end{scope}
        
        \begin{scope}
            \clip (90:\h) arc (90:270:0.3*\h cm and \h cm) arc (-90:90:\h);
            \fill[ball color=col8,shading=ball] (C) circle (\h cm);
        \end{scope}

    \end{tikzpicture}
\end{document}

enter image description here

6
  • 1
    Its a very cool image!
    – Jes
    Feb 5 at 21:29
  • 2
    It is really great!!!! Thanx a lot Feb 6 at 6:38
  • 2
    Very very nice....+1.
    – Sebastiano
    Feb 6 at 10:08
  • 1
    I edited my post and added a new picture.
    – SebGlav
    Feb 6 at 15:01
  • 2
    Beautiful! Splendid, literally!
    – AlexG
    Feb 6 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.