| 1 |
% This is |
| 2 |
% pkqueen.mf |
| 3 |
% |
| 4 |
% Copyright (C) 1989-92 by Elmar Bartel. |
| 5 |
% |
| 6 |
% This program is free software; you can redistribute it and/or modify |
| 7 |
% it under the terms of the GNU General Public License as published by |
| 8 |
% the Free Software Foundation; either version 1, or (at your option) |
| 9 |
% any later version. |
| 10 |
% |
| 11 |
% This program is distributed in the hope that it will be useful, |
| 12 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
% GNU General Public License for more details. |
| 15 |
% |
| 16 |
% You should have received a copy of the GNU General Public License |
| 17 |
% along with this program; if not, write to the Free Software |
| 18 |
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 |
% |
| 20 |
|
| 21 |
%we have to define six essential characters: |
| 22 |
% WoW NoW BoW WoB NoB BoB |
| 23 |
%Pawn 0 6 12 18 24 30 |
| 24 |
%Knight 1 7 13 19 25 31 |
| 25 |
%Bishop 2 8 14 20 26 32 |
| 26 |
%Rook 3 9 15 21 27 33 |
| 27 |
%Queen 4 10 16 22 28 34 |
| 28 |
%King 5 11 17 23 29 35 |
| 29 |
|
| 30 |
def Kegel(expr p,q) = |
| 31 |
begingroup |
| 32 |
path KPath; |
| 33 |
numeric Width[],x[].a,y[].a,x[].b,y[].b; |
| 34 |
numeric Base,MiddlePos,BowIns,Height,LowerHeight,TopHeight; |
| 35 |
|
| 36 |
|
| 37 |
Width0 = Base = length(q-p); |
| 38 |
Width1 = 1.30Base; |
| 39 |
Width2 = 0.35Base; |
| 40 |
Width3 = 1.30Base; % Diameter of circle |
| 41 |
Height = 5.75Base; |
| 42 |
MiddlePos = 0.25; |
| 43 |
|
| 44 |
BowIns = Width3/2+-+Width2/2; |
| 45 |
LowerHeight + TopHeight = Height - Width3 + BowIns; |
| 46 |
LowerHeight = MiddlePos*(LowerHeight+TopHeight); |
| 47 |
|
| 48 |
z0a = p; |
| 49 |
z0b = z0a + (Width0,0); |
| 50 |
forsuffixes $=1,2: |
| 51 |
x$a + x$b = x0a + x0b; x$b - x$a = Width$; |
| 52 |
endfor; |
| 53 |
y1a = y1b = y0a + LowerHeight; |
| 54 |
y2a = y2b = y1a + TopHeight; |
| 55 |
x3a = .5(x2b+x2a); |
| 56 |
y3a = y2a + BowIns; |
| 57 |
%labels(0a,0b,1a,1b,2a,2b,3a); |
| 58 |
|
| 59 |
path LeftP,RightP,KgCircle; |
| 60 |
LeftP= z2a -- z1a -- z0a; |
| 61 |
RightP= z0b -- z1b -- z2b; |
| 62 |
KgCircle= halfcircle rotated 180 scaled Width3 shifted z3a; |
| 63 |
|
| 64 |
KPath:= RightP .. |
| 65 |
subpath ((ypart((z1b -- 1.5[z1b,z2b]) |
| 66 |
intersectiontimes KgCircle)),4) of KgCircle .. |
| 67 |
halfcircle scaled Width3 shifted z3a .. |
| 68 |
subpath (0,ypart((z1a -- 1.5[z1a,z2a]) |
| 69 |
intersectiontimes KgCircle)) of KgCircle .. |
| 70 |
LeftP; |
| 71 |
reverse (KPath rotatedaround(p, angle (q-p))) |
| 72 |
endgroup; |
| 73 |
enddef; |
| 74 |
|
| 75 |
def DefineQueenPath = |
| 76 |
%SetParam; |
| 77 |
DefineFootBows( 0, % No Space to Bottom |
| 78 |
.50qs, % BowOneWidth |
| 79 |
.28qs, % FootHeight |
| 80 |
.40, % BowTwoLoc |
| 81 |
.13, % WidthToHeight |
| 82 |
.90, % BowTwoLen |
| 83 |
1.00); % BowThreeLen |
| 84 |
|
| 85 |
path KPath,LeftPath,RightPath,QueenShape; |
| 86 |
numeric b,s; |
| 87 |
% b and s define the ratio of 5 peak bases and 4 spaces. |
| 88 |
% if you want more or other spacing change the values |
| 89 |
b = 1.1s; |
| 90 |
5b + 4s = length(Bow3); |
| 91 |
|
| 92 |
pair at,bt; |
| 93 |
at= point 0 of Bow3; |
| 94 |
bt= point b of Bow3; |
| 95 |
KPath:= Kegel(at, bt); |
| 96 |
for t=b+s step b+s until length(Bow3): |
| 97 |
KPath:= KPath .. subpath(t-s,t) of Bow3; |
| 98 |
KPath:= KPath .. Kegel(point t of Bow3, |
| 99 |
point(t+b)of Bow3); |
| 100 |
endfor; |
| 101 |
LeftPath:= z1l .. z2l .. z3l; |
| 102 |
RightPath:= z3r .. z2r .. z1r; |
| 103 |
QueenShape:= Bow0 & |
| 104 |
LeftPath & |
| 105 |
KPath .. |
| 106 |
RightPath & |
| 107 |
cycle; |
| 108 |
enddef; |
| 109 |
|
| 110 |
pickup chess_pen; |
| 111 |
|
| 112 |
def MakeWhiteQueen = |
| 113 |
clearit; |
| 114 |
pickup chess_pen; |
| 115 |
draw QueenShape; |
| 116 |
forsuffixes $=1,2,3: draw Bow$; endfor; |
| 117 |
WhiteMan:= currentpicture; |
| 118 |
enddef; |
| 119 |
|
| 120 |
def MakeBlackQueen = |
| 121 |
clearit; |
| 122 |
pickup chess_pen; |
| 123 |
filldraw QueenShape; |
| 124 |
cullit; |
| 125 |
undraw ShortenPath(Bow1,thin); |
| 126 |
undraw ShortenPath(Bow2,thin); |
| 127 |
undraw ShortenPath(ParallelPath(Bow3,-thin),thin); |
| 128 |
BlackMan:= currentpicture; |
| 129 |
enddef; |
| 130 |
|
| 131 |
def MakeOuterShape = |
| 132 |
clearit; |
| 133 |
pickup frame_pen; |
| 134 |
filldraw QueenShape; |
| 135 |
cullit; |
| 136 |
OuterShape:= currentpicture; |
| 137 |
enddef; |
| 138 |
|
| 139 |
DefineQueenPath; |
| 140 |
MakeWhiteQueen; |
| 141 |
MakeBlackQueen; |
| 142 |
MakeNeutral(WhiteMan,BlackMan); |
| 143 |
MakeOuterShape; |
| 144 |
|
| 145 |
%----------------------------------------------------------------------- |
| 146 |
beginchar(Queen+White+OnWhite, qs#, qs#, 0); |
| 147 |
"White queen on white field"; |
| 148 |
currentpicture:= WhiteMan; |
| 149 |
endchar; |
| 150 |
|
| 151 |
beginchar(Queen+White+OnWhite+LeftTurned, qs#, qs#, 0); |
| 152 |
"White queen on white field rotated to the left"; |
| 153 |
currentpicture:= TurnLeft(WhiteMan); |
| 154 |
endchar; |
| 155 |
|
| 156 |
beginchar(Queen+White+OnWhite+RightTurned, qs#, qs#, 0); |
| 157 |
"White queen on white field rotated to the right"; |
| 158 |
currentpicture:= TurnRight(WhiteMan); |
| 159 |
endchar; |
| 160 |
|
| 161 |
beginchar(Queen+White+OnWhite+UpSideDown, qs#, qs#, 0); |
| 162 |
"White queen on white field upside down"; |
| 163 |
currentpicture:= TurnUpSideDown(WhiteMan); |
| 164 |
endchar; |
| 165 |
|
| 166 |
beginchar(Queen+Black+OnWhite, qs#, qs#, 0); |
| 167 |
"Black queen on white field"; |
| 168 |
currentpicture:= BlackMan; |
| 169 |
endchar; |
| 170 |
|
| 171 |
beginchar(Queen+Black+OnWhite+LeftTurned, qs#, qs#, 0); |
| 172 |
"Black queen on white field rotated to the left"; |
| 173 |
currentpicture:= TurnLeft(BlackMan); |
| 174 |
endchar; |
| 175 |
|
| 176 |
beginchar(Queen+Black+OnWhite+RightTurned, qs#, qs#, 0); |
| 177 |
"Black queen on white field rotated to the right"; |
| 178 |
currentpicture:= TurnRight(BlackMan); |
| 179 |
endchar; |
| 180 |
|
| 181 |
beginchar(Queen+Black+OnWhite+UpSideDown, qs#, qs#, 0); |
| 182 |
"Black queen on white field upside down"; |
| 183 |
currentpicture:= TurnUpSideDown(BlackMan); |
| 184 |
endchar; |
| 185 |
|
| 186 |
beginchar(Queen+Neutral+OnWhite, qs#, qs#, 0); |
| 187 |
"Neutral queen on white field"; |
| 188 |
currentpicture:= NeutralMan; |
| 189 |
endchar; |
| 190 |
|
| 191 |
beginchar(Queen+Neutral+OnWhite+LeftTurned, qs#, qs#, 0); |
| 192 |
"Neutral queen on white field rotated to the left"; |
| 193 |
currentpicture:= TurnLeft(NeutralMan); |
| 194 |
endchar; |
| 195 |
|
| 196 |
beginchar(Queen+Neutral+OnWhite+RightTurned, qs#, qs#, 0); |
| 197 |
"Neutral queen on white field rotated to the right"; |
| 198 |
currentpicture:= TurnRight(NeutralMan); |
| 199 |
endchar; |
| 200 |
|
| 201 |
beginchar(Queen+Neutral+OnWhite+UpSideDown, qs#, qs#, 0); |
| 202 |
"Neutral queen on white field upside down"; |
| 203 |
currentpicture:= TurnUpSideDown(NeutralMan); |
| 204 |
endchar; |
| 205 |
|
| 206 |
beginchar(Queen+White+OnBlack, qs#, qs#, 0); |
| 207 |
"White queen on black field"; |
| 208 |
MakeBlackField; |
| 209 |
currentpicture:= currentpicture - OuterShape; |
| 210 |
cullit; |
| 211 |
currentpicture:= currentpicture + WhiteMan; |
| 212 |
endchar; |
| 213 |
|
| 214 |
beginchar(Queen+White+OnBlack+LeftTurned, qs#, qs#, 0); |
| 215 |
"White queen on black field turned to the left"; |
| 216 |
MakeBlackField; |
| 217 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 218 |
cullit; |
| 219 |
currentpicture:= currentpicture + TurnLeft(WhiteMan); |
| 220 |
endchar; |
| 221 |
|
| 222 |
beginchar(Queen+White+OnBlack+RightTurned, qs#, qs#, 0); |
| 223 |
"White queen on black field turned to the right"; |
| 224 |
MakeBlackField; |
| 225 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 226 |
cullit; |
| 227 |
currentpicture:= currentpicture + TurnRight(WhiteMan); |
| 228 |
endchar; |
| 229 |
|
| 230 |
beginchar(Queen+White+OnBlack+UpSideDown, qs#, qs#, 0); |
| 231 |
"White queen on black field upsidedown"; |
| 232 |
MakeBlackField; |
| 233 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 234 |
cullit; |
| 235 |
currentpicture:= currentpicture + TurnUpSideDown(WhiteMan); |
| 236 |
endchar; |
| 237 |
|
| 238 |
beginchar(Queen+Neutral+OnBlack, qs#, qs#, 0); |
| 239 |
"Neutral queen on black field"; |
| 240 |
MakeBlackField; |
| 241 |
currentpicture:= currentpicture - OuterShape; |
| 242 |
cullit; |
| 243 |
currentpicture:= currentpicture + NeutralMan; |
| 244 |
endchar; |
| 245 |
|
| 246 |
beginchar(Queen+Neutral+OnBlack+LeftTurned, qs#, qs#, 0); |
| 247 |
"Neutral queen on black field turned to the left"; |
| 248 |
MakeBlackField; |
| 249 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 250 |
cullit; |
| 251 |
currentpicture:= currentpicture + TurnLeft(NeutralMan); |
| 252 |
endchar; |
| 253 |
|
| 254 |
beginchar(Queen+Neutral+OnBlack+RightTurned, qs#, qs#, 0); |
| 255 |
"Neutral queen on black field turned to the right"; |
| 256 |
MakeBlackField; |
| 257 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 258 |
cullit; |
| 259 |
currentpicture:= currentpicture + TurnRight(NeutralMan); |
| 260 |
endchar; |
| 261 |
|
| 262 |
beginchar(Queen+Neutral+OnBlack+UpSideDown, qs#, qs#, 0); |
| 263 |
"Neutral queen on black field upsidedown"; |
| 264 |
MakeBlackField; |
| 265 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 266 |
cullit; |
| 267 |
currentpicture:= currentpicture + TurnUpSideDown(NeutralMan); |
| 268 |
endchar; |
| 269 |
|
| 270 |
beginchar(Queen+Black+OnBlack, qs#, qs#, 0); |
| 271 |
"Black queen on black field"; |
| 272 |
MakeBlackField; |
| 273 |
currentpicture:= currentpicture - OuterShape; |
| 274 |
cullit; |
| 275 |
currentpicture:= currentpicture + BlackMan; |
| 276 |
endchar; |
| 277 |
|
| 278 |
beginchar(Queen+Black+OnBlack+LeftTurned, qs#, qs#, 0); |
| 279 |
"Black queen on black field turned to the left"; |
| 280 |
MakeBlackField; |
| 281 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 282 |
cullit; |
| 283 |
currentpicture:= currentpicture + TurnLeft(BlackMan); |
| 284 |
endchar; |
| 285 |
|
| 286 |
beginchar(Queen+Black+OnBlack+RightTurned, qs#, qs#, 0); |
| 287 |
"Black queen on black field turned to the right"; |
| 288 |
MakeBlackField; |
| 289 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 290 |
cullit; |
| 291 |
currentpicture:= currentpicture + TurnRight(BlackMan); |
| 292 |
endchar; |
| 293 |
|
| 294 |
beginchar(Queen+Black+OnBlack+UpSideDown, qs#, qs#, 0); |
| 295 |
"Black queen on black field upsidedown"; |
| 296 |
MakeBlackField; |
| 297 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 298 |
cullit; |
| 299 |
currentpicture:= currentpicture + TurnUpSideDown(BlackMan); |
| 300 |
endchar; |