| 1 |
%====================================================================== |
| 2 |
% This is |
| 3 |
% queen.mf |
| 4 |
% |
| 5 |
% Copyright (C) 1989-93 by Elmar Bartel. |
| 6 |
% |
| 7 |
% This program is free software; you can redistribute it and/or modify |
| 8 |
% it under the terms of the GNU General Public License as published by |
| 9 |
% the Free Software Foundation; either version 1, or (at your option) |
| 10 |
% any later version. |
| 11 |
% |
| 12 |
% This program is distributed in the hope that it will be useful, |
| 13 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
% GNU General Public License for more details. |
| 16 |
% |
| 17 |
% You should have received a copy of the GNU General Public License |
| 18 |
% along with this program; if not, write to the Free Software |
| 19 |
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 |
%====================================================================== |
| 21 |
|
| 22 |
def OneCurl (expr a,da, b,db, above, pangle) = |
| 23 |
begingroup |
| 24 |
save dx, dy, p; |
| 25 |
pair dx; dx= b-a; |
| 26 |
pair dy; dy= dx rotated 90; |
| 27 |
pair p; p= (a+.5dx+above*dy); |
| 28 |
a{da} .. {dx rotated pangle}p & |
| 29 |
p{dx rotated -pangle} .. {db}b |
| 30 |
endgroup |
| 31 |
enddef; |
| 32 |
|
| 33 |
def SplitPath(suffix $) % the first suffix of z |
| 34 |
(expr p, % the path |
| 35 |
n, % how often |
| 36 |
shdelta % the shift multiplier |
| 37 |
% it's used to 'drift' the points |
| 38 |
% away from the center |
| 39 |
) = |
| 40 |
% This makro takes a path, and defines n eqhal spaced |
| 41 |
% good points on the path. If shdelta is a small amount |
| 42 |
% greater zero, the pieces are smaller at the end of the |
| 43 |
% path. |
| 44 |
begingroup |
| 45 |
pair dl[]; |
| 46 |
pair dr[]; |
| 47 |
numeric i,l,r,delta; |
| 48 |
|
| 49 |
i= 0; |
| 50 |
l= 0; |
| 51 |
r= length(p); |
| 52 |
delta= length(p)/n; |
| 53 |
forever: |
| 54 |
if i = n-i: |
| 55 |
z$l[i] = z$r[i] = point .5length(p) of p; |
| 56 |
dl[i] = dr[i] = direction .5length(p) of p; |
| 57 |
else: |
| 58 |
numeric shift; |
| 59 |
if i=0: shift = 0 else: shift = (n-i)*shdelta*delta fi; |
| 60 |
z$l[i] = good.lft (point (l-shift) of p); |
| 61 |
dl[i] = direction (l-shift) of p; |
| 62 |
z$r[i] = good.rt (point (r+shift) of p); |
| 63 |
dr[i] = direction (r+shift) of p; |
| 64 |
fi |
| 65 |
l:= l+delta; |
| 66 |
r:= r-delta; |
| 67 |
exitif r-l < 0; |
| 68 |
i:= incr i; |
| 69 |
endfor; |
| 70 |
for i:= incr i step 1 until n: |
| 71 |
z$l[i] = z$r[n-i]; |
| 72 |
z$r[i] = z$l[n-i]; |
| 73 |
dl[i] = dr[n-i]; |
| 74 |
dr[i] = dl[n-i]; |
| 75 |
endfor; |
| 76 |
endgroup |
| 77 |
enddef; |
| 78 |
|
| 79 |
def CurlPath(suffix $) |
| 80 |
(expr p, % the path |
| 81 |
n, % how often |
| 82 |
above, % the peak above the path |
| 83 |
pangle, % the direction at the peak |
| 84 |
shdelta % the shift multiplier |
| 85 |
% it's used to 'drift' the points |
| 86 |
% away from the center |
| 87 |
) = |
| 88 |
begingroup |
| 89 |
save dl, dr; |
| 90 |
save i,l,r,delta,shift; |
| 91 |
SplitPath($, p, n, shdelta); |
| 92 |
OneCurl(z$l0, dl0, z$l1, dl1, above, pangle) |
| 93 |
for i:= 2 step 1 until n: |
| 94 |
& OneCurl(z$l[i-1], dl[i-1], z4l[i], dl[i], above, pangle) |
| 95 |
endfor |
| 96 |
endgroup |
| 97 |
enddef; |
| 98 |
|
| 99 |
def SplitPoints(suffix $) % The same definition as SplitPath |
| 100 |
(expr p, % the path |
| 101 |
n, % how often |
| 102 |
shdelta % the shift multiplier |
| 103 |
% it's used to 'drift' the points |
| 104 |
% away from the center |
| 105 |
) = |
| 106 |
begingroup |
| 107 |
save dl, dr; |
| 108 |
save i,l,r,delta,shift; |
| 109 |
SplitPath($, p, n, shdelta); |
| 110 |
endgroup |
| 111 |
enddef; |
| 112 |
|
| 113 |
def Kegel(expr p,q) = |
| 114 |
begingroup |
| 115 |
path KPath; |
| 116 |
numeric Width[],x[].a,y[].a,x[].b,y[].b; |
| 117 |
numeric Base,MiddlePos,BowIns,Height,LowerHeight,TopHeight; |
| 118 |
|
| 119 |
|
| 120 |
Width0 = Base = length(q-p); |
| 121 |
Width1 = 1.30Base; |
| 122 |
Width2 = 0.35Base; |
| 123 |
Width3 = 1.30Base; % Diameter of circle |
| 124 |
Height = 5.75Base; |
| 125 |
MiddlePos = 0.25; |
| 126 |
|
| 127 |
BowIns = Width3/2+-+Width2/2; |
| 128 |
LowerHeight + TopHeight = Height - Width3 + BowIns; |
| 129 |
LowerHeight = MiddlePos*(LowerHeight+TopHeight); |
| 130 |
|
| 131 |
z0a = p; |
| 132 |
z0b = z0a + (Width0,0); |
| 133 |
forsuffixes $=1,2: |
| 134 |
x$a + x$b = x0a + x0b; x$b - x$a = Width$; |
| 135 |
endfor; |
| 136 |
y1a = y1b = y0a + LowerHeight; |
| 137 |
y2a = y2b = y1a + TopHeight; |
| 138 |
x3a = .5(x2b+x2a); |
| 139 |
y3a = y2a + BowIns; |
| 140 |
%labels(0a,0b,1a,1b,2a,2b,3a); |
| 141 |
|
| 142 |
path LeftP,RightP,KgCircle; |
| 143 |
LeftP= z2a -- z1a -- z0a; |
| 144 |
RightP= z0b -- z1b -- z2b; |
| 145 |
KgCircle= halfcircle rotated 180 scaled Width3 shifted z3a; |
| 146 |
|
| 147 |
path KPath; |
| 148 |
KPath:= RightP .. |
| 149 |
subpath ((ypart((z1b -- 1.5[z1b,z2b]) |
| 150 |
intersectiontimes KgCircle)),4) of KgCircle .. |
| 151 |
halfcircle scaled Width3 shifted z3a .. |
| 152 |
subpath (0,ypart((z1a -- 1.5[z1a,z2a]) |
| 153 |
intersectiontimes KgCircle)) of KgCircle .. |
| 154 |
LeftP; |
| 155 |
reverse (KPath rotatedaround(p, angle (q-p))) |
| 156 |
endgroup; |
| 157 |
enddef; |
| 158 |
|
| 159 |
def cCircle (expr bl, br, t, r) = |
| 160 |
% draw a circle with diameter r clockweise(!) at top |
| 161 |
% of triangle bl,br,t |
| 162 |
(reverse (halfcircle & halfcircle rotated 180)) |
| 163 |
scaled r shifted (left*.5r) rotated angle(.5[bl,br]-t) shifted t |
| 164 |
enddef; |
| 165 |
|
| 166 |
def DefineQueenPath(expr n) = |
| 167 |
%SetParam; |
| 168 |
DefineFootBows(-.034qs, % No Space to Bottom |
| 169 |
.72qs, % BowOneWidth |
| 170 |
.26qs, % FootHeight |
| 171 |
.40, % BowTwoLoc |
| 172 |
.15, % WidthToHeight |
| 173 |
.66, % BowTwoLen |
| 174 |
0.66); % BowThreeLen |
| 175 |
|
| 176 |
% This is not needed for the fs-Type of queen. |
| 177 |
% path KPath, |
| 178 |
% numeric b,s; |
| 179 |
% % b and s define the ratio of 5 peak bases and 4 spaces. |
| 180 |
% % if you want more or other spacing change the values |
| 181 |
% b = 1.1s; |
| 182 |
% 5b + 4s = length(Bow3); |
| 183 |
% |
| 184 |
% pair at,bt; |
| 185 |
% at= point 0 of Bow3; |
| 186 |
% bt= point b of Bow3; |
| 187 |
% KPath:= Kegel(at, bt); |
| 188 |
% for t=b+s step b+s until length(Bow3): |
| 189 |
% KPath:= KPath .. subpath(t-s,t) of Bow3; |
| 190 |
% KPath:= KPath .. Kegel(point t of Bow3, |
| 191 |
% point(t+b)of Bow3); |
| 192 |
% endfor; |
| 193 |
|
| 194 |
% Some correction of the lower bows, to make |
| 195 |
% the corners more round |
| 196 |
Bow0:= ShortenPath(Bow0, 5thin); |
| 197 |
Bow1:= ShortenPath(Bow1, 5thin); |
| 198 |
x1l:= lft(x1l + 2.5thin); |
| 199 |
x1r:= rt(x1r - 2.5thin); |
| 200 |
Bow0:= z1r{down} .. Bow0 .. {up}z1l; |
| 201 |
Bow1:= z1l{up} .. Bow1 .. {down}z1r; |
| 202 |
|
| 203 |
Bow4:= Lengthen(ParallelPath(Bow3, .10qs), .05qs); |
| 204 |
z4l = good.lft (point 0 of Bow4); |
| 205 |
z4 = point .5length(Bow4) of Bow4; |
| 206 |
z4r = good.rt point infinity of Bow4; |
| 207 |
Bow4:= z4l {direction 0 of Bow4} .. |
| 208 |
z4 {right} .. |
| 209 |
z4r {direction infinity of Bow4}; |
| 210 |
|
| 211 |
Bow4:= CurlPath(4, Bow4, n, .15, 35, .04); |
| 212 |
|
| 213 |
z5l = good.lft (SideSpace, .72qs); |
| 214 |
z5r = good.rt (qs-SideSpace, .72qs); |
| 215 |
show z5l, z5r; |
| 216 |
z5 = (.5qs, .83qs); |
| 217 |
Bow5 = z5l .. z5 .. z5r; |
| 218 |
SplitPoints(5, Bow5, n-1, .01); |
| 219 |
|
| 220 |
path cPath; |
| 221 |
cPath = z4l0 |
| 222 |
for i=0 step 1 until n-1: |
| 223 |
& z4l[i] -- z5l[i] & |
| 224 |
cCircle(z4l[i],z4l[i+1],z5l[i],.09qs) -- z4l[i+1] |
| 225 |
endfor; |
| 226 |
|
| 227 |
path LeftPath,RightPath,QueenShape; |
| 228 |
LeftPath:= z1l -- z2l -- z3l -- z4l; |
| 229 |
RightPath:= z4r -- z3r -- z2r -- z1r; |
| 230 |
QueenShape:= Bow0 & |
| 231 |
LeftPath & |
| 232 |
cPath & |
| 233 |
RightPath & |
| 234 |
cycle; |
| 235 |
enddef; |
| 236 |
|
| 237 |
pickup chess_pen; |
| 238 |
|
| 239 |
def MakeWhiteQueen = |
| 240 |
clearit; |
| 241 |
pickup chess_pen; |
| 242 |
draw QueenShape; |
| 243 |
%forsuffixes $=0,1,2,3,4,5: undraw z4r$; endfor; |
| 244 |
%forsuffixes $=0,1,2,3,4,5: draw z4l$; endfor; |
| 245 |
%forsuffixes $=0,1,2,3,4: draw z5l$; endfor; |
| 246 |
forsuffixes $=1,2,3,4: draw Bow$; endfor; |
| 247 |
WhiteMan:= currentpicture; |
| 248 |
enddef; |
| 249 |
|
| 250 |
def MakeBlackQueen = |
| 251 |
clearit; |
| 252 |
pickup chess_pen scaled 1.1; |
| 253 |
filldraw QueenShape; |
| 254 |
cullit; |
| 255 |
forsuffixes $=1,2,3: |
| 256 |
undraw ShortenPath(Bow$, thin); |
| 257 |
endfor; |
| 258 |
BlackMan:= currentpicture; |
| 259 |
enddef; |
| 260 |
|
| 261 |
def MakeOuterShape = |
| 262 |
clearit; |
| 263 |
pickup frame_pen; |
| 264 |
filldraw QueenShape; |
| 265 |
cullit; |
| 266 |
OuterShape:= currentpicture; |
| 267 |
enddef; |
| 268 |
|
| 269 |
DefineQueenPath(5); |
| 270 |
MakeWhiteQueen; |
| 271 |
MakeBlackQueen; |
| 272 |
MakeNeutral(WhiteMan,BlackMan); |
| 273 |
MakeOuterShape; |
| 274 |
|
| 275 |
%=========================================================== |
| 276 |
% this one for testing |
| 277 |
%beginchar(Queen+White+OnBlack, qs#, qs#, 0); |
| 278 |
% "White queen on black field"; |
| 279 |
% MakeBlackField; |
| 280 |
% currentpicture:= currentpicture - OuterShape; |
| 281 |
% cullit; |
| 282 |
% currentpicture:= currentpicture + WhiteMan; |
| 283 |
%endchar; |
| 284 |
%endinput |
| 285 |
%=========================================================== |
| 286 |
|
| 287 |
beginchar(Queen+White+OnWhite, qs#, qs#, 0); |
| 288 |
"White queen on white field"; |
| 289 |
currentpicture:= WhiteMan; |
| 290 |
endchar; |
| 291 |
|
| 292 |
beginchar(Queen+White+OnWhite+LeftTurned, qs#, qs#, 0); |
| 293 |
"White queen on white field rotated to the left"; |
| 294 |
currentpicture:= TurnLeft(WhiteMan); |
| 295 |
endchar; |
| 296 |
|
| 297 |
beginchar(Queen+White+OnWhite+RightTurned, qs#, qs#, 0); |
| 298 |
"White queen on white field rotated to the right"; |
| 299 |
currentpicture:= TurnRight(WhiteMan); |
| 300 |
endchar; |
| 301 |
|
| 302 |
beginchar(Queen+White+OnWhite+UpSideDown, qs#, qs#, 0); |
| 303 |
"White queen on white field upside down"; |
| 304 |
currentpicture:= TurnUpSideDown(WhiteMan); |
| 305 |
endchar; |
| 306 |
|
| 307 |
beginchar(Queen+Black+OnWhite, qs#, qs#, 0); |
| 308 |
"Black queen on white field"; |
| 309 |
currentpicture:= BlackMan; |
| 310 |
endchar; |
| 311 |
|
| 312 |
beginchar(Queen+Black+OnWhite+LeftTurned, qs#, qs#, 0); |
| 313 |
"Black queen on white field rotated to the left"; |
| 314 |
currentpicture:= TurnLeft(BlackMan); |
| 315 |
endchar; |
| 316 |
|
| 317 |
beginchar(Queen+Black+OnWhite+RightTurned, qs#, qs#, 0); |
| 318 |
"Black queen on white field rotated to the right"; |
| 319 |
currentpicture:= TurnRight(BlackMan); |
| 320 |
endchar; |
| 321 |
|
| 322 |
beginchar(Queen+Black+OnWhite+UpSideDown, qs#, qs#, 0); |
| 323 |
"Black queen on white field upside down"; |
| 324 |
currentpicture:= TurnUpSideDown(BlackMan); |
| 325 |
endchar; |
| 326 |
|
| 327 |
beginchar(Queen+Neutral+OnWhite, qs#, qs#, 0); |
| 328 |
"Neutral queen on white field"; |
| 329 |
currentpicture:= NeutralMan; |
| 330 |
endchar; |
| 331 |
|
| 332 |
beginchar(Queen+Neutral+OnWhite+LeftTurned, qs#, qs#, 0); |
| 333 |
"Neutral queen on white field rotated to the left"; |
| 334 |
currentpicture:= TurnLeft(NeutralMan); |
| 335 |
endchar; |
| 336 |
|
| 337 |
beginchar(Queen+Neutral+OnWhite+RightTurned, qs#, qs#, 0); |
| 338 |
"Neutral queen on white field rotated to the right"; |
| 339 |
currentpicture:= TurnRight(NeutralMan); |
| 340 |
endchar; |
| 341 |
|
| 342 |
beginchar(Queen+Neutral+OnWhite+UpSideDown, qs#, qs#, 0); |
| 343 |
"Neutral queen on white field upside down"; |
| 344 |
currentpicture:= TurnUpSideDown(NeutralMan); |
| 345 |
endchar; |
| 346 |
|
| 347 |
beginchar(Queen+White+OnBlack, qs#, qs#, 0); |
| 348 |
"White queen on black field"; |
| 349 |
MakeBlackField; |
| 350 |
currentpicture:= currentpicture - OuterShape; |
| 351 |
cullit; |
| 352 |
currentpicture:= currentpicture + WhiteMan; |
| 353 |
endchar; |
| 354 |
|
| 355 |
beginchar(Queen+White+OnBlack+LeftTurned, qs#, qs#, 0); |
| 356 |
"White queen on black field turned to the left"; |
| 357 |
MakeBlackField; |
| 358 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 359 |
cullit; |
| 360 |
currentpicture:= currentpicture + TurnLeft(WhiteMan); |
| 361 |
endchar; |
| 362 |
|
| 363 |
beginchar(Queen+White+OnBlack+RightTurned, qs#, qs#, 0); |
| 364 |
"White queen on black field turned to the right"; |
| 365 |
MakeBlackField; |
| 366 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 367 |
cullit; |
| 368 |
currentpicture:= currentpicture + TurnRight(WhiteMan); |
| 369 |
endchar; |
| 370 |
|
| 371 |
beginchar(Queen+White+OnBlack+UpSideDown, qs#, qs#, 0); |
| 372 |
"White queen on black field upsidedown"; |
| 373 |
MakeBlackField; |
| 374 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 375 |
cullit; |
| 376 |
currentpicture:= currentpicture + TurnUpSideDown(WhiteMan); |
| 377 |
endchar; |
| 378 |
|
| 379 |
beginchar(Queen+Neutral+OnBlack, qs#, qs#, 0); |
| 380 |
"Neutral queen on black field"; |
| 381 |
MakeBlackField; |
| 382 |
currentpicture:= currentpicture - OuterShape; |
| 383 |
cullit; |
| 384 |
currentpicture:= currentpicture + NeutralMan; |
| 385 |
endchar; |
| 386 |
|
| 387 |
beginchar(Queen+Neutral+OnBlack+LeftTurned, qs#, qs#, 0); |
| 388 |
"Neutral queen on black field turned to the left"; |
| 389 |
MakeBlackField; |
| 390 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 391 |
cullit; |
| 392 |
currentpicture:= currentpicture + TurnLeft(NeutralMan); |
| 393 |
endchar; |
| 394 |
|
| 395 |
beginchar(Queen+Neutral+OnBlack+RightTurned, qs#, qs#, 0); |
| 396 |
"Neutral queen on black field turned to the right"; |
| 397 |
MakeBlackField; |
| 398 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 399 |
cullit; |
| 400 |
currentpicture:= currentpicture + TurnRight(NeutralMan); |
| 401 |
endchar; |
| 402 |
|
| 403 |
beginchar(Queen+Neutral+OnBlack+UpSideDown, qs#, qs#, 0); |
| 404 |
"Neutral queen on black field upsidedown"; |
| 405 |
MakeBlackField; |
| 406 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 407 |
cullit; |
| 408 |
currentpicture:= currentpicture + TurnUpSideDown(NeutralMan); |
| 409 |
endchar; |
| 410 |
|
| 411 |
beginchar(Queen+Black+OnBlack, qs#, qs#, 0); |
| 412 |
"Black queen on black field"; |
| 413 |
MakeBlackField; |
| 414 |
currentpicture:= currentpicture - OuterShape; |
| 415 |
cullit; |
| 416 |
currentpicture:= currentpicture + BlackMan; |
| 417 |
endchar; |
| 418 |
|
| 419 |
beginchar(Queen+Black+OnBlack+LeftTurned, qs#, qs#, 0); |
| 420 |
"Black queen on black field turned to the left"; |
| 421 |
MakeBlackField; |
| 422 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 423 |
cullit; |
| 424 |
currentpicture:= currentpicture + TurnLeft(BlackMan); |
| 425 |
endchar; |
| 426 |
|
| 427 |
beginchar(Queen+Black+OnBlack+RightTurned, qs#, qs#, 0); |
| 428 |
"Black queen on black field turned to the right"; |
| 429 |
MakeBlackField; |
| 430 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 431 |
cullit; |
| 432 |
currentpicture:= currentpicture + TurnRight(BlackMan); |
| 433 |
endchar; |
| 434 |
|
| 435 |
beginchar(Queen+Black+OnBlack+UpSideDown, qs#, qs#, 0); |
| 436 |
"Black queen on black field upsidedown"; |
| 437 |
MakeBlackField; |
| 438 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 439 |
cullit; |
| 440 |
currentpicture:= currentpicture + TurnUpSideDown(BlackMan); |
| 441 |
endchar; |