diff options
Diffstat (limited to 'macros/latex/contrib/cchess/cchessboard.tex')
-rw-r--r-- | macros/latex/contrib/cchess/cchessboard.tex | 257 |
1 files changed, 257 insertions, 0 deletions
diff --git a/macros/latex/contrib/cchess/cchessboard.tex b/macros/latex/contrib/cchess/cchessboard.tex new file mode 100644 index 0000000000..539fc2e923 --- /dev/null +++ b/macros/latex/contrib/cchess/cchessboard.tex @@ -0,0 +1,257 @@ +\documentstyle{article} +% cchessboard.tex +% +% papier 8.5in x 11in = 21.59cm x 27.94cm +% dessin 17.6cm x 19.8cm +%\hoffset=-0.545cm% devrait etre la bonne valeur, mais...!?? +\hoffset=-1.545cm + +\setlength{\textwidth}{20cm}\setlength{\textheight}{22cm} +\setlength{\oddsidemargin}{0cm}\setlength{\evensidemargin}{0cm} +\setlength{\topmargin}{0cm}\setlength{\headheight}{0cm} + +% If the font size is changed, the macro WhiteMask must also be changed +\newfont{\EchecsChinois}{cchess46} +\newcounter{piecex}\newcounter{piecey} + +\special{! /WhiteMask + { + gsave + [] 0 setdash 0 setlinejoin 0 setlinecap +% the gray level could be changed to 0.95, for light gray pieces that stand out +% better on a white board. Here, it is set to full white (0.0 is full black). + 1.0 setgray +% Here, the 102 was determined by trial and error. Must find an algebraic way to fix it! +% that's the radius of the masking circle. + 102 dup scale + currentpoint translate newpath 0. 0. 1. 0. 360. arc closepath fill + grestore + } def } + +\newcommand{\piece}[3]{% macro pour afficher une piece +\setcounter{piecex}{#1}\addtocounter{piecex}{-1}% +\setcounter{piecey}{#2}\addtocounter{piecey}{-1}% +\put(\value{piecex},\value{piecey}){\special{" grestore WhiteMask gsave}}% +\put(\value{piecex},\value{piecey})% +{\setbox0=\hbox{\EchecsChinois #3}\kern-0.5\wd0\box0}% +} + +\begin{document} +\thispagestyle{empty} +\begin{center} +\setlength{\unitlength}{2.2cm}% +\begin{picture}(8.1,9.1)% +\put(0,0){\framebox(8,9){}}% +\put(-0.05,-0.05){\framebox(8.1,9.1){}}% +% +\newsavebox{\Something}% +\savebox{\Something}(8,1)[bl]{% +\multiput(0,0)(1,0){8}{\framebox(1,1){}}}% +% +\multiput(0,0)(0,1){4}{\usebox{\Something}}% +\multiput(0,5)(0,1){4}{\usebox{\Something}}% +% +\newsavebox{\SW}\newsavebox{\SE}\newsavebox{\NE}\newsavebox{\NW}% +\savebox{\SW}(1,1)[bl]{% +\put(0.1,0.1){\line(1,0){0.2}}\put(0.1,0.1){\line(0,1){0.2}}}% +\savebox{\SE}(1,1)[bl]{% +\put(0.9,0.1){\line(-1,0){0.2}}\put(0.9,0.1){\line(0,1){0.2}}}% +\savebox{\NE}(1,1)[bl]{% +\put(0.9,0.9){\line(-1,0){0.2}}\put(0.9,0.9){\line(0,-1){0.2}}}% +\savebox{\NW}(1,1)[bl]{% +\put(0.1,0.9){\line(1,0){0.2}}\put(0.1,0.9){\line(0,-1){0.2}}}% +% On va commencer par faire les "croix" completes +\savebox{\Something}(2,2)[bl]{% +\put(0,0){\usebox{\NE}}\put(1,0){\usebox{\NW}}\put(1,1){\usebox{\SW}}\put(0,1){\usebox{\SE}}}% +% +\put(0,1){\usebox{\Something}}% +\put(6,1){\usebox{\Something}}% +\put(1,2){\usebox{\Something}}% +\put(3,2){\usebox{\Something}}% +\put(5,2){\usebox{\Something}}% +% +\put(0,6){\usebox{\Something}}% +\put(6,6){\usebox{\Something}}% +\put(1,5){\usebox{\Something}}% +\put(3,5){\usebox{\Something}}% +\put(5,5){\usebox{\Something}}% +% Maintenant les demi-croix gauches +\savebox{\Something}(1,2)[bl]{% +\put(0,0){\usebox{\NW}}\put(0,1){\usebox{\SW}}}% +\put(0,2){\usebox{\Something}}% +\put(0,5){\usebox{\Something}}% +% ...les demi-croix droites +\savebox{\Something}(1,2)[bl]{% +\put(0,0){\usebox{\NE}}\put(0,1){\usebox{\SE}}}% +\put(7,2){\usebox{\Something}}% +\put(7,5){\usebox{\Something}}% +% +% et pour finir, les camps des generaux: +\savebox{\Something}(2,2)[bl]{% +\put(0,0){\line(1,1){2}}% La "longueur" a fournir est celle de la projection horizontale +\put(2,0){\line(-1,1){2}}}% +\put(3,0){\usebox{\Something}}% +\put(3,7){\usebox{\Something}}% +% +\piece{1}{1}{r}\piece{9}{1}{r}% +\piece{2}{1}{n}\piece{8}{1}{n}% +\piece{3}{1}{b}\piece{7}{1}{b}% +\piece{4}{1}{g}\piece{6}{1}{g}% +\piece{2}{3}{c}\piece{8}{3}{c}% +\piece{1}{4}{p}\piece{3}{4}{p}\piece{5}{4}{p}\piece{7}{4}{p}\piece{9}{4}{p}% +\piece{5}{1}{k}% +\piece{1}{10}{R}\piece{9}{10}{R}% +\piece{2}{10}{N}\piece{8}{10}{N}% +\piece{3}{10}{B}\piece{7}{10}{B}% +\piece{4}{10}{G}\piece{6}{10}{G}% +\piece{2}{8}{C}\piece{8}{8}{C}% +\piece{1}{7}{P}\piece{3}{7}{P}\piece{5}{7}{P}\piece{7}{7}{P}\piece{9}{7}{P}% +\piece{5}{10}{K}% +%\piece{4}{5}{0}\put(3.3,4.4){\large Masque}% +\end{picture} +\end{center} +\end{document} +cut here------8<---- cchess46.mf ----8<----------------------- +cut here------8<-----ccpieces.mf-----8<----------------------- +cut here------8<----------------------8<----------------------- +Over the last few months, I have spent several nights coding a Chinese +chess (xiangqi) font. I had a cheap chess set I bought in Montreal's +Chinatown a long time ago; +in spite of the fact that I only paid 1US$ for it, its pieces have a +nice pleasing look. So I have undertaken to reproduce it as faithfully as I +could. The set was made in (communist) China, and bears no copyright +mark of any kind; in the true communist spirit, I now distribute this font +to you, and hope no one will try to sue me for it! + +I tried to be true to the original design, although no two pieces of the same +kind really looked the same under close examination. I had to guess the +intent of the designer. The model pieces were made of pale wood, about 3/4" +in diameter, with etched characters painted red and dark green. + +This was my first serious METAFONT experience, and my lack of +experience can be seen transpiring throughout the code. The style of my +coding evolved slightly as I progressed but I could not afford to redo the +first pieces; so the code suffers from some inconsistency in style. I also +got a little tired in the end, and decided to cut short some +descriptions; for example, all corners of the earlier pieces are rounded to +various degrees. This was intentional: I wanted the font to look like +painted characters (on the real pieces, paint always produced rounded +corners, in spite of the etching). In the last pieces I coded, I used a few +overlapping paths, which produce sharper corners at intersection points. I +kept those to a minimum, using them only for brush strokes that are +clearly intersecting ones. + +I called the pieces RED and BLACK. The red pieces are generated as black +on a white background, inside a thin black circle. The black pieces are +generated as white on a black circular background, with a thin white +circle near the edge; these look like negatives of the original green pieces. + +For those who might prefer the look of pieces painted on a white +background (like in the original set), I added a modified copy of the black +pieces, in which they are generated as black on a white background, +surrounded by TWO circles; this gives the edge a much darker look, and +makes clear the distinction between black and red. These could be used to +produce colored pieces on a white background, and still be recognizable if +printed only in black and white. I recommend printing the whole font with +one of the =fonttable.tex= utilities. + +I also added two filled pieces that might be useful as masks. + +The encoding is a simple and natural one for the regular pieces, +using capital letters for BLACK, lowercase for RED; for the third set of +pieces (let's call it "alternate-black"), I had to use the remaining letters +of the alphabet; I opted for consecutive ones. Here they are, with some of +their common names: + + + K,k,S : king, general, + G,g,T : guard, assistant + B,b,U : bishop, elephant + N,n,V : knight,horse + R,r,W : rook, chariot, car + C,c,X : cannon, gun, gunner + P,p,Y : pawn, foot-soldier + + [J,0: masks (not part of the game)] + + + +BOARD DRAWING CODE: + +If used as ordinary letters in text, the circular pieces will be nearly +tangent to the baseline. I defined a macro to place them CENTERED at the +current point in a picture environment. With the unit length properly +chosen, one can then easily draw a Chinese chess board, and place any +piece at any board position by simply =\putting= the piece letter (the +macro will change the font) at the desired (x,y) integer valued coordinates +(x=1..9, y=1..10) (it should be easy to change this to the usual +numerical/alphabetical notation). + + Example: \piece{8}{10}{N} places a black knight in file 8, rank 10. + +I have included a LaTeX file to draw such a board, with each piece in its +starting position. Only the last lines need changing (in an obvious way) to +draw an arbitrary game situation (the board could do with a little decoration +in the river!). + +Printer fonts normally behave like dark characters on a ***transparent*** +background. When placing a piece on the chessboard, one has to ERASE ANY +UNDERLYING LINES FIRST. I could not think of a way of doing this using only +TeX and/or METAFONT. So my piece placing macro uses a little bit of +PostScript code to do this. For that reason, it will only work with DVI -> +PS converters that support dvips=s raw-PS code insertion command +(\special{! ...} and \special{! ...}). + +Unfortunately, the font size (46pt) is presently hardcoded into this LaTeX +file. To print smaller boards, one would have to change a small number of +dimension parameters (margins, picture unitlength, PS mask size) as well as +the font size. I have not had time to implement and test automatic scaling +relations at the LaTeX level. + +I have set the font normal and quad spaces to the diameter of the pieces, +and the font x height to half that diameter. These can be used for kerning, +instead of using the width/height/depth of character boxes. All characters +have the same box dimensions. + + +THE PACKAGE: + +It consists in 3 files, appended at the end of this text, in this order +(look for the "cut here" lines): + +1) the LaTeX file cchessboard.tex for drawing a starting board + (or any other game position) + +2) the METAFONT driver file cchess46.mf for generating the 46pt cchess + font used by cchessboard.tex + +3) the main METAFONT character definition file, ccpieces.mf + +Some comments are in English, some are in French (I like to believe that +my native and favorite language is not dead yet). They are not important +since the whole thing is very simple. + +Before I end, I would like to thank Barry Smith, of Blue Sky Research, for +helping me during my early attempts at generating fonts on a Macintosh +(MacPlus!), using their METAFONT implementation. + + + Jacques Richer, Ph.D. (Physics) + Centre de Recherche en Calcul Applique + 5160, boul. Decarie, bureau 434, + Montreal, PQ, CANADA H3X 2H9 + + TEL: (514) 369-5234 + FAX: (514) 343-3880 + INTERNET: richer@cerca.umontreal.ca + +(my address at work could change very soon) + + Home address: + 7029, rue Marquette + Montreal, Quebec, + CANADA H2E 2C6 + + +cut here------8<------- cchessboard.tex ------8<------------------ + |