I'm using Sandy G's formula here, basically the .707^<level>
part.
Two approaches:
- PGF and LuaLaTeX that uses JLDiaz' great poisson lua script.
- TikZ and PGFmath that just uses the
rnd
function.
The macro \pgfpointspiralifdefined
makes sure that coordinates that have been calculated already don't need to have be recalculated.
Instead of the coordinate a
, b
, c
and d
, you can also use the vertex
anchors of the kite shape that Sandy G's answer uses (you need to name the nodes of course, e.g. spiral-\l-\n
).
In both solutions I'm cubing one of the random values so that the points get bunched to one side of the kites.
PGF + LuaLaTeX
\documentclass{standalone}
\usepackage{pgf,pgffor}
\usepackage{jldiaz-poisson}% https://tex.stackexchange.com/a/185423/16595
\usepackage{xcolor} % colorwheel
\definecolor{cw0}{HTML}{9AFF00}\definecolor{cw1}{HTML}{FFA500}
\definecolor{cw2}{HTML}{FF001A}\definecolor{cw3}{HTML}{FF00D9}
\definecolor{cw4}{HTML}{6500FF}\definecolor{cw5}{HTML}{005AFF}
\definecolor{cw6}{HTML}{00FFE5}\definecolor{cw7}{HTML}{00FF25}
\pgfset{
declare function={
spiralAngle(\level,\spiral) = \directlua{tex.print(
180/(\pgfkeysvalueof{/pgf/spiral\space N})*\level
+360/(\pgfkeysvalueof{/pgf/spiral\space N})*\spiral)};
spiralRadius(\level) = \directlua{tex.print(
.707^\level*(\pgfkeysvalueof{/pgf/spiral\space radius}))};
xSpread(\n)=\n^3*.8+.1; ySpread(\n)=\n*.8+.1;},
spiral radius/.initial=5, spiral N/.initial=8}
\newcommand*\pgfpointspiral[2]{% #1 = level, #2 = spiral
\pgfpointpolarxy{spiralAngle(#1,#2)}{spiralRadius(#1)}}
\makeatletter
\newcommand*\pgfpointspiralifdefined[3]{%
% if spiral-#2-#3 doesn't exist, define it
% if it does do nothing
\pgfutil@ifundefined{pgf@sh@ns@spiral-#2-#3}{%
\pgfcoordinate{spiral-#2-#3}{\pgfpointspiral{#2}{#3}}%
}{}% and make it an alias for #1
\pgfnodealias{#1}{spiral-#2-#3}}
\makeatother
\begin{document}
\begin{pgfpicture}
\pgfsetxvec{\pgfqpoint{5mm}{0mm}}
\pgfsetyvec{\pgfqpoint{0mm}{5mm}}
\foreach \l in {0,...,6}{
\foreach \n in {0,...,7}{
\pgfpointspiralifdefined{a}{\l} {\n}
\pgfpointspiralifdefined{b}{\inteval{\l+1}}{\n}
\pgfpointspiralifdefined{c}{\l} {\inteval{\n+1}}
\pgfpointspiralifdefined{d}{\inteval{\l-1}}{\inteval{\n+1}}
\pgfsetfillcolor{cw\n}
\foreach[expand list, evaluate={\xSpread=xSpread(\x);}]
\x/\y in {\poissonpointslist{1}{1}{.02+.0\l}{10}} {
\pgfpathcircle{
\pgfpointlineattime{ySpread(\y)}
{\pgfpointlineattime{\xSpread}
{\pgfpointanchor{a}{center}}{\pgfpointanchor{b}{center}}}
{\pgfpointlineattime{\xSpread}
{\pgfpointanchor{d}{center}}{\pgfpointanchor{c}{center}}}
}{+.25pt}
\pgfusepath{fill}
}
}
}
\end{pgfpicture}
\end{document}
TikZ + PGFmath
The \pgfpointspiralifdefined
could have also been implemented by a custom TikZ coordinate system but why bother …
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\pgfset{
declare function={
xSpread(\n)=\n^3*.8+.1; ySpread(\n)=\n*.8+.1;},
spiral radius/.initial=5,
spiral N/.initial=8}
\newcommand*\pgfpointspiral[2]{% #1 = level, #2 = spiral
\pgfpointpolarxy{180/(\pgfkeysvalueof{/pgf/spiral N})*(#1)
+360/(\pgfkeysvalueof{/pgf/spiral N})*(#2)}
{.707^(#1)*(\pgfkeysvalueof{/pgf/spiral radius})}}
\makeatletter
\newcommand*\pgfpointspiralifdefined[3]{%
\pgfutil@ifundefined{pgf@sh@ns@spiral-#2-#3}{%
\pgfcoordinate{spiral-#2-#3}{\pgfpointspiral{#2}{#3}}%
}{}%
\pgfnodealias{#1}{spiral-#2-#3}}
\makeatother
\begin{document}
\begin{tikzpicture}[x=+5mm, y=+5mm]
\foreach \l[evaluate={\Dots=250*.7^\l}] in {0,...,6} {
\foreach \n in {0,...,7} {
\pgfpointspiralifdefined{a}{\l} {\n}
\pgfpointspiralifdefined{b}{\inteval{\l+1}}{\n}
\pgfpointspiralifdefined{c}{\l} {\inteval{\n+1}}
\pgfpointspiralifdefined{d}{\inteval{\l-1}}{\inteval{\n+1}}
\fill[radius=+.4pt] foreach[
evaluate={\xSpread=xSpread rnd; \ySpread=ySpread rnd;}]
\dot in {0,...,\Dots} {
($($(a)!\ySpread!(d)$)!\xSpread!($(b)!\ySpread!(c)$)$)
circle[radius=+.4pt]};
}
}
\end{tikzpicture}
\end{document}
Output

pic
element. 3) Learn how to use the command($(p)! c! angle: (p)$)
which produces the image of the pointq
through a direct similarity of centerp
, ratioc
, and angleangle
. 4) Do some mathematics for one of the spirals and create it with thepic
and the above similarity. 5) Use a\foreach
loop to have your eight leaves. 6) Modify the filling of the elementary quadrilateral (in the initialpic
) to have the desired effect.