-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisc.tex
57 lines (55 loc) · 1.88 KB
/
disc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% Stacked disks
% Author: Mark Wibrow
\documentclass[tikz,border=10pt]{standalone}
%%%<
\usepackage{verbatim}
%%%>
\begin{comment}
:Title: Stacked discs in 3d
:Tags: Foreach;Pic;3d;Decorative drawings
:Author: Mark Wibrow
:Slug: disc
To draw a stack of disks with a 3d impression, we use
the pic element, which is new in TikZ 3.0 and can be considered
like combining a node and a tikzpicture.
This example was written by Mark Wibrow answering a question on TeX.SE.
\end{comment}
\tikzset{
pics/.cd,
disc/.style = {
code = {
\fill [white] ellipse [x radius = 2, y radius = 2/3];
\path [left color = black!50, right color = black!50,
middle color = black!25]
(-2+.05,-1.1) arc (180:360:2-.05 and 2/3-.05*2/3) -- cycle;
\path [top color = black!25, bottom color = white]
(0,.05*2/3) ellipse [x radius = 2-.05, y radius = 2/3-.05*2/3];
\path [left color = black!25, right color = black!25,
middle color = white] (-2,0) -- (-2,-1) arc (180:360:2 and 2/3)
-- (2,0) arc (360:180:2 and 2/3);
\foreach \r in {225,315}
\foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
\fill [black, fill opacity = 1/50]
(0,0) -- (\r+\s-\i:2 and 2/3) -- ++(0,-1)
arc (\r+\s-\i:\r-\s+\i:2 and 2/3) -- ++(0,1) -- cycle;
\foreach \r in {45,135}
\foreach \i [evaluate = {\s=30;}] in {0,2,...,30}
\fill [black, fill opacity = 1/50]
(0,0) -- (\r+\s-\i:2 and 2/3)
arc (\r+\s-\i:\r-\s+\i:2 and 2/3) -- cycle;
}
},
disc bottom/.style = {
code = {
\foreach \i in {0,2,...,30}
\fill [black, fill opacity = 1/60] (0,-1.1)
ellipse [x radius = 2+\i/40, y radius = 2/3+\i/60];
\path pic {disc};
}
}
}
\begin{document}
\begin{tikzpicture}
\path (0,0) pic {disc bottom} (0,1.25) pic {disc} (0,2.5) pic {disc};
\end{tikzpicture}
\end{document}