3

If I have list for iching (bagua) trigrams as follows, what is the best way to generate 64 hexagrams as in shown in the image attached? I can use the use the binary code (e.g.{1,1,1}) for either color coding or draw the trigrams inspired from here, or use the unicode here. Is nested for-loop the right approach? This is probably too much to ask.

{1,1,1}; 乾; 8;  ☰
{1,1,0}; 兌; 7;  ☱
{1,0,1}; 離; 6;  ☲
{1,0,0}; 震; 5;  ☳
{0,0,0}; 坤; 1;  ☷
{0,0,1}; 艮; 2;  ☶
{0,1,0}; 坎; 3;  ☵
{0,1,1}; 巽; 4;  ☴

enter image description here

5

I apologize in advance that I am not able to use these characters. So I am assuming that you know how to use them (and what they mean). This answer just creates an array of Latin characters and Arabic numbers. You may thus want to redefine \lstchar to your needs.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
  \def\lstchar{{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 
 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", 
 "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", 
 "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", 
 "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", 
 "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", 
 "8", "9", "+", "-"}}
  \foreach \Z [evaluate=\Z as \Y using {int(\Z/8)},
  evaluate=\Z as \X using {int(mod(\Z,8))}] 
  in {0,1,2,...,63}
 {
 \pgfmathtruncatemacro{\x}{mod(\Z,4)*255/3}
 \pgfmathtruncatemacro{\y}{mod(int(\Z/4),4)*255/3}
 \pgfmathtruncatemacro{\z}{mod(int(\Z/16),4)*255/3}
 \pgfmathsetmacro{\char}{\lstchar[\Z]}
 \definecolor{mycolor\Z}{RGB}{\z,\y,\x}
 \node[color=mycolor\Z,rotate={\Z*(360/64)-90},scale=1.5] at ({\Z*(360/64)}:7) {\char};
 \node[color=mycolor\Z,scale=1.5] at (\X-4+0.5,4-\Y-0.5) {\char};
 }
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much for your effort, @marmot. Your solution explains the placement elegantly. I will explore how to stack the 8 trigrams to generate 64 hexagrams. – Tony Tan Jan 30 at 22:27
  • 1
    @TonyTan You can put tabulars in the nodes. Just replace the node commands in my code by \node[color=mycolor\Z,rotate={\Z*(360/64)-90},scale=1.5] at ({\Z*(360/64)}:7) {\begin{tabular}{c} \char\\[-2mm] \char\\[-2mm] \char \end{tabular}}; \node[color=mycolor\Z,scale=1.5] at (\X-4+0.5,4-\Y-0.5) { \begin{tabular}{c} \char\\[-2mm] \char\\[-2mm] \char \end{tabular}};. Of course you can define more lists and thus get different characters. – user121799 Jan 30 at 22:32
  • If you want to display the hexagrams, one font that contains them is DejaVu Sans, and they have Unicode code points U+4DC0 to U+4DFF. – Davislor Jan 31 at 4:24
  • @Davislor Thanks! However, I hesitate to produce texts that I do not understand. But of course you could write an answer, I am curious how that looks. – user121799 Jan 31 at 4:36
  • @marmot Yes, good point. Especially since the symbols apparently have some kind of religious significance, of which I’m wholly ignorant. – Davislor Jan 31 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.