This example was developed in response to the question
A rather difficult ring like picture to be drawn
on TeX.SE.
It makes use of the ext.misc
library of the tikz-ext
bundle of which it uses
- the
declare constant
key which is similar to thedeclare function
key but doesn’t accepts any functions (and can be changed later on) - the
full arc
key with theR
postfix operator which emulates PSTricks\segments
function as well as - the
use int
key for\foreach
which sets up a list to loop through where every element is evaluated beforehand.
The code actually draws almost the same picture.
However, in the first drawing the \foreach
loop’s body is one whole TikZ path which – as demonstrated – can have different properties.
In the second drawing, the loop is actually part of the sole path (apart from the nodes) and leaves out the radial dividers.
The whole diagram is one path and can be filled/shaded as such.
\documentclass[tikz]{standalone} \usetikzlibrary{ext.misc} \begin{document} \begin{tikzpicture}[ declare function={bigR(\n)=smallR+.05*\n;}, declare constant={smallR=1; segments=20;}, full arc=segments] \foreach \iN[evaluate={\endRadius=bigR(\iN+1);}, use int=0 to segments-1] \filldraw[fill/.pgfmath wrap={green!##1!blue}{100*\iN/segments}] (\iN R:\endRadius) arc [radius=\endRadius, start angle=\iN R, delta angle=+1R] -- (\iN R+1R:smallR) arc [radius=smallR, end angle=\iN R, delta angle=-1R] -- cycle; \node {$\phi^2$}; \node at (north west:{sqrt 2 * bigR(segments/2)}) {$\{\Omega\}_{i=1}^n$}; \node[rotate=-.5R, right] at (-.5R: bigR segments) {$\partial \varphi$}; \tikzset{xshift=5cm, declare constant={segments=25;}, full arc=segments} \filldraw[left color=red, right color=yellow] (right:smallR) foreach \iN[evaluate={\endRadius=bigR(\iN+1);}, use int=0 to segments-1] { -- (\iN R:\endRadius) arc[radius=\endRadius, start angle=\iN R, delta angle=1R]} -- (right:smallR) arc[radius=smallR, start angle=0, delta angle=-360]; \node {$\phi^2$}; \node at (north west:{sqrt 2 * bigR(segments/2)}) {$\{\Omega\}_{i=1}^n$}; \node[rotate=-.5R, right] at (-.5R: bigR segments) {$\partial \varphi$}; \end{tikzpicture} \end{document}