-
Notifications
You must be signed in to change notification settings - Fork 0
/
pattern-yijing.tex
84 lines (76 loc) · 3.06 KB
/
pattern-yijing.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NOTE. It takes a good minute to typeset
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff
\begin{document}
\Repeat{2}{
\begin{tikzpicture}[line width=0.030in]
\clip (0,0) rectangle (8.5in,11in);
\foreach \sec in {0,...,0}{
\foreach \row in {0,...,25}{
\foreach \col in {0,...,19}{
\foreach \bar in {0,...,5}{
\draw ({0.300in+\col*0.400in}, {0.365in+\bar*0.054in+\row*0.400in+\sec*11.000in}) coordinate (xy);
\pgfmathtruncatemacro\val{mod(floor(mod(\col + 20*\row+520*\sec,64)/2^\bar),2)}
\ifnum\val=0\draw (xy) -- ++(right:0.100in) ++(right:0.100in) -- ++(right:0.100in);
\else\draw (xy) -- ++(right:0.300in);\fi
}}}}
%\draw[step=0.1in, thin] (0,0) grid (8.5in,11in);
\end{tikzpicture}
}
\Repeat{2}{
\begin{tikzpicture}[line width=0.030in]
\clip (0,0) rectangle (8.5in,11in);
\foreach \sec in {0,...,4}{
\foreach \row in {0,...,3}{
\foreach \col in {0,...,19}{
\foreach \bar in {0,...,5}{
\draw ({0.300in+\col*0.400in}, {0.365in+\bar*0.054in+\row*0.400in+\sec*2.200in}) coordinate (xy);
\pgfmathtruncatemacro\val{mod(floor(mod(\col + 20*\row+80*\sec,64)/2^\bar),2)}
\ifnum\val=0\draw (xy) -- ++(right:0.100in) ++(right:0.100in) -- ++(right:0.100in);
\else\draw (xy) -- ++(right:0.300in);\fi
}}}}
%\draw[step=0.1in, thin] (0,0) grid (8.5in,11in);
\end{tikzpicture}
}
\end{document}
%%%%%%%%%%%%%%%
% GENERATE TIKZ CODE
%%%%%%%%%%%%%%%
def tikzhexagrams(numsecs, numrows, numcols,
leftmargin, barlen, xsep,
botmargin, barwidth, barsep, ysep):
print("\\Repeat{2}{")
print("\\begin{tikzpicture}", end="") ## {} = \u007B \u007B
print(f"[line width={barwidth:.3f}in]")
print("\\clip (0,0) rectangle (8.5in,11in);")
print("\\foreach \\sec in {0,...," + str(numsecs - 1) + "}{")
print("\\foreach \\row in {0,...," + str(numrows - 1) + "}{")
print("\\foreach \\col in {0,...," + str(numcols - 1) + "}{")
print("\\foreach \\bar in {0,...,5}{")
print(f"\\draw (\u007B{leftmargin:.3f}in", end="")
print(f"+\\col*{xsep+barlen:.3f}in\u007D, ", end="")
print(f"\u007B{botmargin + 0.5*barwidth:.3f}in", end="")
print(f"+\\bar*{barwidth+barsep:.3f}in", end="")
print(f"+\\row*{6*barwidth+5*barsep+ysep:.3f}in", end="")
print(f"+\\sec*{11/numsecs:.3f}in\u007D) ", end="")
print("coordinate (xy);")
print("\\pgfmathtruncatemacro\\val{", end="")
print(f"mod(floor(mod(\\col + {numcols}*\\row", end="")
print(f"+{numcols*numrows}*\\sec,64)/2^\\bar),2)\u007D")
print("\\ifnum\\val=0", end="")
print(f"\\draw (xy) -- ++(right:{barlen/3:.3f}in) ", end="")
print(f"++(right:{barlen/3:.3f}in) -- ++(right:{barlen/3:.3f}in);")
print(f"\\else\\draw (xy) -- ++(right:{barlen:.3f}in);\\fi")
print("}}}}")
print("%\draw[step=0.1in, thin] (0,0) grid (8.5in,11in);")
print("\\end{tikzpicture}\n}")
tikzhexagrams(1, 26, 20, 0.3, 0.3, 0.1, 0.35, 0.03, 0.024, 0.1)
tikzhexagrams(5, 4, 20, 0.3, 0.3, 0.1, 0.35, 0.03, 0.024, 0.1)
#tikzhexagrams(5, 5, 21, 0.2, 0.3, 0.09, 0.2, 0.03 0.024, 0.075)
#tikzhexagrams(5, 5, 20, 0.3, 0.3, 0.1, 0.3, 0.02, 0.02, 0.125)