blob: 8e4e0e12121700e5ec2c8045722cdb37f8e28b9d (
plain) (
blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
\documentclass[border=10cm]{standalone}
\usepackage{pgf}
\newcount\ulami
\newcount\ulamj
\newcount\ulamlen
\newcount\ulamx
\newcount\ulamy
\newcount\ulamdx
\newcount\ulamdy
\ulami=1 %
\ulamj=0 %
\ulamlen=1 %
\ulamdx=-1 %
\ulamdy=1 %
\ulamx=0 %
\ulamy=0 %
\def\ulamplot#1{%
\advance\ulami by 1 %
\advance\ulamj by 1 %
\advance\ulamx by \the\ulamdx %
\advance\ulamy by \the\ulamdy %
\pgfpathmoveto{\pgfpoint{\the\ulamx cm}{\the\ulamy cm}}
\pgfmathparse{isprime(\the\ulami)}
\let\r=\pgfmathresult
\ifnum\r=1
\pgfpathcircle{\pgfpoint{\the\ulamx cm}{\the\ulamy cm}}{5pt}
\fi
\ifnum\ulamj=\the\ulamlen %
\advance\ulamlen by 1 %
\ulamj=0 %
\ifnum\ulamdx=1 %
\ulamdx=-1 %
\ulamdy=1 %
\else%
\ifnum\ulamdx=-1 %
\ulamdx=0 %
\ulamdy=-1 %
\else%
\ulamdx=1 %
\ulamdy=0 %
\fi
\fi
\fi
\ifnum#1>0 %
\advance#1 by -1 %
\ulamplot{#1}%
\fi
}
\begin{document}
\begin{pgfpicture}
\pgfmathsetmacro{\x}{cos(60)}
\pgfmathsetmacro{\y}{sin(60)}
\pgftransformcm{1}{0}{\x}{\y}{\pgfpointorigin}
\pgfpathmoveto{\pgfpointorigin}
\color{blue}
\newcount\ulamn
\ulamn=400
\ulamplot{\ulamn}
\pgfusepath{stroke,fill}
\end{pgfpicture}
\end{document}
|