| 1 |
%====================================================================== |
| 2 |
% This is |
| 3 |
% pawn.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 |
% This is the oldest part of all my the MF-sources. |
| 22 |
% I started Metafonting with this figure. |
| 23 |
% ElB. |
| 24 |
%====================================================================== |
| 25 |
|
| 26 |
%----------------------------------------------------------- |
| 27 |
% This macro depends on some global sizes: |
| 28 |
% thin, BottomSpace, BottomWidth, sidewith |
| 29 |
% The values are defined as basic sizes of the Chess Characters |
| 30 |
|
| 31 |
def PawnShape(expr wbf,hbf,wmf,hmf,wtf,htf,ibm,imt) = |
| 32 |
%begingroup |
| 33 |
%save wb,wm,wt,hb,hm,ht,interbm,intermt; |
| 34 |
numeric wb,wm,wt,hb,hm,ht,interbm,intermt; |
| 35 |
wb = BottomWidth*wbf; % width of bottom ellipse |
| 36 |
hb = hbf*wb; % hight of bottom ellipse |
| 37 |
wm = wmf*wb; hm = hmf*wm; % width and hight of middle ellipse |
| 38 |
wt = wtf*wb; ht = htf*wt; % width and hight of top ellipse |
| 39 |
interbm = ibm*thin; % amount of intersection of bottom |
| 40 |
% and middle |
| 41 |
intermt = imt*thin; % amount of intersection of middle |
| 42 |
%and top |
| 43 |
%save superb,superm,supert; |
| 44 |
numeric superb,superm,supert; |
| 45 |
superb=.73; |
| 46 |
superm=.75; |
| 47 |
supert=.73; |
| 48 |
|
| 49 |
%save topb,topm,topt; |
| 50 |
numeric topb,topm,topt; |
| 51 |
topb=BottomSpace+hb; |
| 52 |
topm=topb+hm-interbm; |
| 53 |
topt=topm+ht-intermt; |
| 54 |
|
| 55 |
%screenrule((0,BottomSpace),(qs,BottomSpace)); |
| 56 |
%screenrule(((qs-wb)/2,0),((qs-wb)/2,qs)); |
| 57 |
%screenrule(((qs+wb)/2,0),((qs+wb)/2,qs)); |
| 58 |
|
| 59 |
%screenrule((0,topb),(qs,topb)); |
| 60 |
%screenrule((0,topm),(qs,topm)); |
| 61 |
%screenrule((0,topt),(qs,topt)); |
| 62 |
|
| 63 |
%save bp,mp,tp; |
| 64 |
numeric bp,mp,tp; |
| 65 |
path bp,mp,tp,PawnPath; |
| 66 |
|
| 67 |
%save x,y,z; |
| 68 |
%pair z[]b,x[]b,y[]b; |
| 69 |
%pair z[]m,x[]m,y[]m; |
| 70 |
%pair z[]t,x[]t,y[]t; |
| 71 |
|
| 72 |
bot rt z1b = ((qs+wb)/2, BottomSpace); |
| 73 |
bot lft z3b = ((qs-wb)/2, BottomSpace); |
| 74 |
bot y4b + hb = top y2b - hb = BottomSpace; |
| 75 |
x2b = x4b = qs/2; |
| 76 |
bp=superellipse(z1b,z2b,z3b,z4b,superb); |
| 77 |
bp:= subpath(0,4) of bp; |
| 78 |
|
| 79 |
rt x1m - wm/2 = lft x3m + wm/2 = qs/2; |
| 80 |
top y2m = bot y4m + hm = topm; |
| 81 |
y1m = y3m = (y2m+y4m)/2; |
| 82 |
x2m = x4m = qs/2; |
| 83 |
mp=superellipse(z1m,z2m,z3m,z4m,superm); |
| 84 |
|
| 85 |
rt x1t - wt/2 = lft x3t + wt/2 = qs/2; |
| 86 |
top y2t = bot y4t + ht = topt; |
| 87 |
y1t = y3t = (y2t+y4t)/2; |
| 88 |
x2t = x4t = qs/2; |
| 89 |
tp=superellipse(z1t,z2t,z3t,z4t,supert); |
| 90 |
|
| 91 |
% compute the intersectiontimes on the right side of the pawn |
| 92 |
% The pathtimes of superellipses range from 0 to 8 |
| 93 |
|
| 94 |
%save scbr,scmbr,scmtr,sctr; |
| 95 |
numeric scbr,scmbr,scmtr,sctr; |
| 96 |
scbr = xpart (bp intersectiontimes (subpath(6,8)of mp)); |
| 97 |
scmbr = xpart (mp intersectiontimes (subpath(0,2)of bp)); |
| 98 |
scmtr = xpart (mp intersectiontimes (subpath(6,8)of tp)); |
| 99 |
sctr = xpart (tp intersectiontimes (subpath(0,2)of mp)); |
| 100 |
|
| 101 |
% here is a macro to mirror pathtimes of superellipses on y-axis |
| 102 |
def mr(expr v) = |
| 103 |
if v > 4: 12-v; |
| 104 |
else: 4-v; |
| 105 |
fi |
| 106 |
enddef; |
| 107 |
|
| 108 |
% Now the left intersectionpoints |
| 109 |
%save scbl,scmbl,scmtl,sctl; |
| 110 |
numeric scbl,scmbl,scmtl,sctl; |
| 111 |
scbl = mr(scbr); |
| 112 |
scmbl = mr(scmbr); |
| 113 |
scmtl = mr(scmtr); |
| 114 |
sctl = mr(sctr); |
| 115 |
|
| 116 |
PawnPath:=subpath(0,scbr)of bp .. |
| 117 |
subpath(scmbr,(8+scmtr)) of mp .. |
| 118 |
subpath(sctr,8+sctl) of tp .. |
| 119 |
subpath(scmtl,scmbl) of mp .. |
| 120 |
subpath(scbl,4) of bp; |
| 121 |
%endgroup |
| 122 |
|
| 123 |
enddef; |
| 124 |
%----------------------------------------------------------- |
| 125 |
def MakePawnPath = |
| 126 |
pickup chess_pen; |
| 127 |
if unknown PawnPath: |
| 128 |
% wb = qs - 2*sidespace; % width of bottom ellipse |
| 129 |
% hb = hbf*wb; % hight of bottom ellipse |
| 130 |
% wm = wmf*wb; hm = hmf*wm; % width and hight of middle |
| 131 |
% ellipse |
| 132 |
% wt = wtf*wb; ht = htf*wt; % width and hight of top |
| 133 |
% ellipse |
| 134 |
% |
| 135 |
% wbf, hbf, ,wmf, hmf, wtf, htf, ibm, imt |
| 136 |
%PawnShape( .80, .50, .55, .85, .3, 1.0, 2.0, 1.2); |
| 137 |
%PawnShape( .85, .55, .60, .90, .4, 1.0, 2.0, 1.2); |
| 138 |
PawnShape( .77, .61, .60, .84, .35, 0.95, 1.8, 1.4); |
| 139 |
fi |
| 140 |
enddef; |
| 141 |
%------------------------------------------------------------ |
| 142 |
def CorrectPawnEdges = |
| 143 |
pickup sqr; |
| 144 |
drawdot(z1b); |
| 145 |
drawdot(z3b); |
| 146 |
enddef; |
| 147 |
%----------------------------------------------------------- |
| 148 |
|
| 149 |
%we have to define six essential characters: |
| 150 |
% WoW NoW BoW WoB NoB BoB |
| 151 |
%Pawn 0 6 12 18 24 30 |
| 152 |
%Knight 1 7 13 19 25 31 |
| 153 |
%Bishop 2 8 14 20 26 32 |
| 154 |
%Rook 3 9 15 21 27 33 |
| 155 |
%Queen 4 10 16 22 28 34 |
| 156 |
%King 5 11 17 23 29 35 |
| 157 |
|
| 158 |
% All these cases are repeated three more times: |
| 159 |
% Left turned, Right turned and upside down |
| 160 |
%------------------------------------------ |
| 161 |
|
| 162 |
|
| 163 |
def MakeWhitePawn = |
| 164 |
pickup chess_pen; |
| 165 |
clearit; |
| 166 |
MakePawnPath; |
| 167 |
draw PawnPath -- cycle; |
| 168 |
cullit; |
| 169 |
WhiteMan:= currentpicture; |
| 170 |
enddef; |
| 171 |
|
| 172 |
def MakeBlackPawn = |
| 173 |
pickup chess_pen; |
| 174 |
clearit; |
| 175 |
MakePawnPath; |
| 176 |
filldraw PawnPath -- cycle; |
| 177 |
cullit; |
| 178 |
BlackMan:= currentpicture; |
| 179 |
enddef; |
| 180 |
|
| 181 |
def MakeOuterShape = |
| 182 |
pickup frame_pen; |
| 183 |
clearit; |
| 184 |
filldraw PawnPath -- cycle; |
| 185 |
cullit; |
| 186 |
OuterShape:= currentpicture; |
| 187 |
enddef; |
| 188 |
|
| 189 |
MakeWhitePawn; |
| 190 |
MakeBlackPawn; |
| 191 |
MakeNeutral(WhiteMan, BlackMan); |
| 192 |
MakeOuterShape; |
| 193 |
|
| 194 |
%=========================================================== |
| 195 |
% this one for testing |
| 196 |
%beginchar(Pawn+White+OnBlack, qs#, qs#, 0); |
| 197 |
% "White pawn on black field"; |
| 198 |
% MakeBlackField; |
| 199 |
% currentpicture:= currentpicture - OuterShape; |
| 200 |
% cullit; |
| 201 |
% currentpicture:= currentpicture + WhiteMan; |
| 202 |
%endchar; |
| 203 |
%endinput |
| 204 |
%=========================================================== |
| 205 |
|
| 206 |
beginchar(Pawn+White+OnWhite, qs#, qs#, 0); |
| 207 |
"White pawn on white field"; |
| 208 |
currentpicture:= WhiteMan; |
| 209 |
endchar; |
| 210 |
|
| 211 |
beginchar(Pawn+White+OnWhite+LeftTurned, qs#, qs#, 0); |
| 212 |
"White pawn on white field rotated to the left"; |
| 213 |
currentpicture:= TurnLeft(WhiteMan); |
| 214 |
endchar; |
| 215 |
|
| 216 |
beginchar(Pawn+White+OnWhite+RightTurned, qs#, qs#, 0); |
| 217 |
"White pawn on white field rotated to the right"; |
| 218 |
currentpicture:= TurnRight(WhiteMan); |
| 219 |
endchar; |
| 220 |
|
| 221 |
beginchar(Pawn+White+OnWhite+UpSideDown, qs#, qs#, 0); |
| 222 |
"White pawn on white field upside down"; |
| 223 |
currentpicture:= TurnUpSideDown(WhiteMan); |
| 224 |
endchar; |
| 225 |
|
| 226 |
beginchar(Pawn+Black+OnWhite, qs#, qs#, 0); |
| 227 |
"Black pawn on white field"; |
| 228 |
currentpicture:= BlackMan; |
| 229 |
endchar; |
| 230 |
|
| 231 |
beginchar(Pawn+Black+OnWhite+LeftTurned, qs#, qs#, 0); |
| 232 |
"Black pawn on white field rotated to the left"; |
| 233 |
currentpicture:= TurnLeft(BlackMan); |
| 234 |
endchar; |
| 235 |
|
| 236 |
beginchar(Pawn+Black+OnWhite+RightTurned, qs#, qs#, 0); |
| 237 |
"Black pawn on white field rotated to the right"; |
| 238 |
currentpicture:= TurnRight(BlackMan); |
| 239 |
endchar; |
| 240 |
|
| 241 |
beginchar(Pawn+Black+OnWhite+UpSideDown, qs#, qs#, 0); |
| 242 |
"Black pawn on white field upside down"; |
| 243 |
currentpicture:= TurnUpSideDown(BlackMan); |
| 244 |
endchar; |
| 245 |
|
| 246 |
beginchar(Pawn+Neutral+OnWhite, qs#, qs#, 0); |
| 247 |
"Neutral pawn on white field"; |
| 248 |
currentpicture:= NeutralMan; |
| 249 |
endchar; |
| 250 |
|
| 251 |
beginchar(Pawn+Neutral+OnWhite+LeftTurned, qs#, qs#, 0); |
| 252 |
"Neutral pawn on white field rotated to the left"; |
| 253 |
currentpicture:= TurnLeft(NeutralMan); |
| 254 |
endchar; |
| 255 |
|
| 256 |
beginchar(Pawn+Neutral+OnWhite+RightTurned, qs#, qs#, 0); |
| 257 |
"Neutral pawn on white field rotated to the right"; |
| 258 |
currentpicture:= TurnRight(NeutralMan); |
| 259 |
endchar; |
| 260 |
|
| 261 |
beginchar(Pawn+Neutral+OnWhite+UpSideDown, qs#, qs#, 0); |
| 262 |
"Neutral pawn on white field upside down"; |
| 263 |
currentpicture:= TurnUpSideDown(NeutralMan); |
| 264 |
endchar; |
| 265 |
|
| 266 |
beginchar(Pawn+White+OnBlack, qs#, qs#, 0); |
| 267 |
"White pawn on black field"; |
| 268 |
MakeBlackField; |
| 269 |
currentpicture:= currentpicture - OuterShape; |
| 270 |
cullit; |
| 271 |
currentpicture:= currentpicture + WhiteMan; |
| 272 |
endchar; |
| 273 |
|
| 274 |
beginchar(Pawn+White+OnBlack+LeftTurned, qs#, qs#, 0); |
| 275 |
"White pawn on black field turned to the left"; |
| 276 |
MakeBlackField; |
| 277 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 278 |
cullit; |
| 279 |
currentpicture:= currentpicture + TurnLeft(WhiteMan); |
| 280 |
endchar; |
| 281 |
|
| 282 |
beginchar(Pawn+White+OnBlack+RightTurned, qs#, qs#, 0); |
| 283 |
"White pawn on black field turned to the right"; |
| 284 |
MakeBlackField; |
| 285 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 286 |
cullit; |
| 287 |
currentpicture:= currentpicture + TurnRight(WhiteMan); |
| 288 |
endchar; |
| 289 |
|
| 290 |
beginchar(Pawn+White+OnBlack+UpSideDown, qs#, qs#, 0); |
| 291 |
"White pawn on black field upsidedown"; |
| 292 |
MakeBlackField; |
| 293 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 294 |
cullit; |
| 295 |
currentpicture:= currentpicture + TurnUpSideDown(WhiteMan); |
| 296 |
endchar; |
| 297 |
|
| 298 |
beginchar(Pawn+Neutral+OnBlack, qs#, qs#, 0); |
| 299 |
"Neutral pawn on black field"; |
| 300 |
MakeBlackField; |
| 301 |
currentpicture:= currentpicture - OuterShape; |
| 302 |
cullit; |
| 303 |
currentpicture:= currentpicture + NeutralMan; |
| 304 |
endchar; |
| 305 |
|
| 306 |
beginchar(Pawn+Neutral+OnBlack+LeftTurned, qs#, qs#, 0); |
| 307 |
"Neutral pawn on black field turned to the left"; |
| 308 |
MakeBlackField; |
| 309 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 310 |
cullit; |
| 311 |
currentpicture:= currentpicture + TurnLeft(NeutralMan); |
| 312 |
endchar; |
| 313 |
|
| 314 |
beginchar(Pawn+Neutral+OnBlack+RightTurned, qs#, qs#, 0); |
| 315 |
"Neutral pawn on black field turned to the right"; |
| 316 |
MakeBlackField; |
| 317 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 318 |
cullit; |
| 319 |
currentpicture:= currentpicture + TurnRight(NeutralMan); |
| 320 |
endchar; |
| 321 |
|
| 322 |
beginchar(Pawn+Neutral+OnBlack+UpSideDown, qs#, qs#, 0); |
| 323 |
"Neutral pawn on black field upsidedown"; |
| 324 |
MakeBlackField; |
| 325 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 326 |
cullit; |
| 327 |
currentpicture:= currentpicture + TurnUpSideDown(NeutralMan); |
| 328 |
endchar; |
| 329 |
|
| 330 |
beginchar(Pawn+Black+OnBlack, qs#, qs#, 0); |
| 331 |
"Black pawn on black field"; |
| 332 |
MakeBlackField; |
| 333 |
currentpicture:= currentpicture - OuterShape; |
| 334 |
cullit; |
| 335 |
currentpicture:= currentpicture + BlackMan; |
| 336 |
endchar; |
| 337 |
|
| 338 |
beginchar(Pawn+Black+OnBlack+LeftTurned, qs#, qs#, 0); |
| 339 |
"Black pawn on black field turned to the left"; |
| 340 |
MakeBlackField; |
| 341 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 342 |
cullit; |
| 343 |
currentpicture:= currentpicture + TurnLeft(BlackMan); |
| 344 |
endchar; |
| 345 |
|
| 346 |
beginchar(Pawn+Black+OnBlack+RightTurned, qs#, qs#, 0); |
| 347 |
"Black pawn on black field turned to the right"; |
| 348 |
MakeBlackField; |
| 349 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 350 |
cullit; |
| 351 |
currentpicture:= currentpicture + TurnRight(BlackMan); |
| 352 |
endchar; |
| 353 |
|
| 354 |
beginchar(Pawn+Black+OnBlack+UpSideDown, qs#, qs#, 0); |
| 355 |
"Black pawn on black field upsidedown"; |
| 356 |
MakeBlackField; |
| 357 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 358 |
cullit; |
| 359 |
currentpicture:= currentpicture + TurnUpSideDown(BlackMan); |
| 360 |
endchar; |