1

I saw the TIkZ example of Mark Wibrow (http://www.texample.net/tikz/examples/disc/). The original answer is here: tikz stacked disks 3D. I need just one disc and I can modify the height of the disc where I can also put the polar coordinates. I was able to reduce the 3 stacked discs to one and put the polar coordinates using Mark's example but can not change the height of the disc. I need to lower it.

  • 1
    Welcome to TeX.se Please edit your question to show your modified code so that people can see what you've done. I've added a link to the original answer on the site. – Alan Munn Apr 14 at 13:24
5

This is a version of Mark's brilliant code which stores the parameters in pgf keys. The parameters are height h, radius r, aspect aspect and a Boolean bottom for the shadow.

\documentclass[tikz,border=10pt]{standalone}
\newif\iftikzdiscisbottom
\tikzset{
  pics/.cd,
  disc/.style = {
    code = {
    \tikzset{disc/.cd,#1}
    \def\pv##1{\pgfkeysvalueof{/tikz/disc/##1}}%
    \iftikzdiscisbottom
      \foreach \i in {0,2,...,30}
        \fill [black, fill opacity = 1/60] (0,-0.1)
          ellipse [x radius = \pv{r}+\i/40, y radius = \pv{r}*\pv{aspect}+\i/60];
    \fi
      \fill (0,\pv{h})[white] ellipse [x radius = \pv{r}, y radius = \pv{r}*\pv{aspect}];
      \path [left color = black!50, right color = black!50,
        middle color = black!25] 
        (-0.975*\pv{r},0) arc[start angle=180,end angle=360,
            x radius=\pv{r}*0.975,y radius=\pv{r}*\pv{aspect}*0.975] -- cycle;
      \path [top color = black!25, bottom color = white] 
        (0,.05*\pv{r}*\pv{aspect}+\pv{h}) 
        ellipse [x radius = 0.975*\pv{r}, y radius = \pv{r}*\pv{aspect}*0.975];
      \path [left color = black!25, right color = black!25,
        middle color = white] (-\pv{r},\pv{h}) -- (-\pv{r},0) 
        arc[start angle=180,end angle=360,
            x radius=\pv{r},y radius=\pv{r}*\pv{aspect}]
        -- (\pv{r},\pv{h}) 
        arc[start angle=360,end angle=180,
            x radius=\pv{r},y radius=\pv{r}*\pv{aspect}];
      \foreach \r in {225,315}
        \foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
          \fill [black, fill opacity = 1/50] 
            (0,\pv{h}) -- ++ (\r+\s-\i:\pv{r} and \pv{r}*\pv{aspect}) 
            -- ++(0,-\pv{h}) 
            arc[start angle=\r+\s-\i,end angle=\r-\s+\i,
            x radius = \pv{r}, y radius = \pv{r}*\pv{aspect}] 
            -- ++(0,\pv{h}) -- cycle;
      \foreach \r in {45,135}
        \foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
          \fill [black, fill opacity = 1/50] 
            (0,\pv{h}) -- ++ (\r+\s-\i:\pv{r} and \pv{r}*\pv{aspect}) 
            arc[start angle=\r+\s-\i,end angle=\r-\s+\i,
            x radius = \pv{r}, y radius = \pv{r}*\pv{aspect}]  -- cycle;
    }
  },/tikz/disc/.cd,h/.initial=1.1,r/.initial=2,aspect/.initial=1/3,
  bottom/.is if=tikzdiscisbottom
}
\begin{document}
\begin{tikzpicture}
\path (0,0) pic {disc={h=2,bottom=true}}
 (5,0) pic {disc={h=3,r=1.5,aspect=1/4}};
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |

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.