| 1 |
%====================================================================== |
| 2 |
% This is |
| 3 |
% knight.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 sympoint (expr p,d,a) = |
| 23 |
% Come to point p in direction d + angel a, and leave symmetrical |
| 24 |
% to d - a This gives us a peak in p pointing in direction d. |
| 25 |
% sharpnes is specified by a. a= 0 no peak, a=90 real peak; |
| 26 |
|
| 27 |
{dir (angle(d)+a)} p {dir(angle(d)+180-a)} |
| 28 |
enddef; |
| 29 |
|
| 30 |
def Ear(expr p,pd,q,qd,a,r,rd) = |
| 31 |
p{pd} .. sympoint(q,qd,a) .. {rd}r |
| 32 |
enddef; |
| 33 |
|
| 34 |
def DefineKnightPath = |
| 35 |
% we construct the path from right to left. |
| 36 |
% Ie we begin with the nack and come then to the ears, |
| 37 |
% the nose etc |
| 38 |
z0 = (.33qs,BottomSpace); % The leftmost bottompoint |
| 39 |
z1 = (qs-SideSpace,BottomSpace); % The right bottom edge |
| 40 |
path Foot; |
| 41 |
Foot = z0 -- z1; |
| 42 |
% z2 will be later defined, it |
| 43 |
% is the connection to the right |
| 44 |
% ear |
| 45 |
z4 = (.465qs,qs-TopSpace+.035qs); % The peak of the right ear |
| 46 |
z3 = z4 + (.042qs,-0.12qs); % The right lower point of the |
| 47 |
% right ear |
| 48 |
z5 = z3 + (-.09qs,.015qs ); % The left lower point of the |
| 49 |
% right ear |
| 50 |
|
| 51 |
% Now comes the definition of the right ear |
| 52 |
% There are two paths: |
| 53 |
% RightEar: The complete path for the ear |
| 54 |
% sRightEar: The subpath for the whole shape |
| 55 |
path RightEar, sRightEar; |
| 56 |
RightEar = Ear(z3,(1,10),z4,(0,1),35,z5,(1,-10)); |
| 57 |
sRightEar = subpath (.25,1.85) of RightEar; |
| 58 |
z2 = point 0 of sRightEar; % The right |
| 59 |
z6 = point 2 of sRightEar; % The left connection point of |
| 60 |
% the right ear |
| 61 |
|
| 62 |
% Now we can also define the nack |
| 63 |
path Nack; |
| 64 |
Nack = z1{up} .. tension 1 and 1 .. {left}z2; |
| 65 |
|
| 66 |
z7 = z6 + (-.08qs,-0.05qs); % This is the point under the |
| 67 |
% left ear |
| 68 |
|
| 69 |
% Now the two pathes from the right to the left ear. |
| 70 |
% EarUnderEar, goes from the right ear under the left ear |
| 71 |
% EarToEar connects only the two ears |
| 72 |
|
| 73 |
path EarUnderEar,EarToEar; |
| 74 |
EarUnderEar= z6{left} .. {-5,-4}z7; |
| 75 |
EarToEar = subpath (0,.4) of EarUnderEar; |
| 76 |
|
| 77 |
z8 = point 1 of EarToEar; % The connection point and the |
| 78 |
% start of the left ear |
| 79 |
|
| 80 |
% to get easier definition of the following points |
| 81 |
% we define a line bx from z7 (point under left ear) down to z13 |
| 82 |
% (leftmost point of shape) ie the begining of nose and mount |
| 83 |
|
| 84 |
z13 = (SideSpace,0.41qs); % The leftmost point of the |
| 85 |
% shape |
| 86 |
pair bx,by; |
| 87 |
bx = z13 - z7; |
| 88 |
by = z13 rotatedabout (z7,-90); |
| 89 |
|
| 90 |
z9 = z7 + .21bx + .21by; % the peak of the left ear |
| 91 |
z10= z7 + .15bx + .08by; % the left point of the left ear |
| 92 |
|
| 93 |
% Now the path for the leaft ear |
| 94 |
path LeftEar; |
| 95 |
LeftEar= Ear(z8,(-1,3),z9,(-1,2),20,z10,(2,-3)); |
| 96 |
|
| 97 |
z11 = z7 + .45bx + .10by; |
| 98 |
z12 = z7 + .50bx + .06by; |
| 99 |
z26 = z7 + .16bx - .02by; % the eye point |
| 100 |
|
| 101 |
path Bless; |
| 102 |
Bless = z10{dir(angle(bx)-15)} .. z11 .. z12 .. {down} z13; |
| 103 |
|
| 104 |
% the points from z14 to z17 are defined via a line nx |
| 105 |
% from z13 to z18 |
| 106 |
pair nx,ny; |
| 107 |
|
| 108 |
z19 = (.255qs,.315qs); |
| 109 |
nx = z19 - z13; |
| 110 |
ny = nx rotatedabout ((0,0),90); |
| 111 |
|
| 112 |
z14 = z13 + .30nx - .22ny; % the point between mouth |
| 113 |
% and nose |
| 114 |
z15 = z13 + .60nx - .15ny; % the upper point of mouth |
| 115 |
z16 = z13 + .70nx + .31ny; % the inner point of mouth |
| 116 |
z17 = z13 + .76nx - .02ny; % |
| 117 |
z18 = z13 + .82nx - .07ny; % |
| 118 |
z25 = z13 + .22nx + .28ny; % the location of the nose |
| 119 |
|
| 120 |
path MouthNose; |
| 121 |
MouthNose = z13 .. z14{nx} .. z15 ... sympoint(z16,(z16-z17),0) |
| 122 |
... z17 .. z18 .. z19; |
| 123 |
|
| 124 |
% the points from z20 to z23 are defined via a line nx |
| 125 |
% from z19 to z23 |
| 126 |
pair ux,uy; |
| 127 |
|
| 128 |
z23 = (.546qs,.64qs); |
| 129 |
ux = z23 - z19; |
| 130 |
uy = z23 rotatedabout (z19,90); |
| 131 |
|
| 132 |
z20 = z19 + .15ux + .01uy; |
| 133 |
z21 = z19 + .45ux - .02uy; |
| 134 |
z22 = z19 + .90ux - .11uy; |
| 135 |
path UnderMouth, sUnderMouth; |
| 136 |
UnderMouth = z19..z20..z21..z22..{up}z23; |
| 137 |
sUnderMouth = subpath (0,3) of UnderMouth; |
| 138 |
|
| 139 |
z24 = z22 + (.008qs,-.05qs); |
| 140 |
path ToFoot; |
| 141 |
%ToFoot = z22..{down}z24 .. {down}z0; |
| 142 |
ToFoot = z22..z24..{down}z0; |
| 143 |
|
| 144 |
|
| 145 |
path KnightShape; |
| 146 |
KnightShape = Foot & Nack & sRightEar & EarToEar |
| 147 |
& LeftEar & Bless & MouthNose |
| 148 |
& sUnderMouth & ToFoot & cycle; |
| 149 |
|
| 150 |
enddef; |
| 151 |
|
| 152 |
def DefineNosePath(expr p,s) = |
| 153 |
begingroup |
| 154 |
if proofing >0: |
| 155 |
show p,s; |
| 156 |
fi; |
| 157 |
save z; pair z[]; |
| 158 |
|
| 159 |
z0 + (0,s) = p; |
| 160 |
pair px,py; |
| 161 |
py= p - z0; |
| 162 |
px= py rotated -90; |
| 163 |
z1= z0 + 0.10px + 0.50py; |
| 164 |
z2= z0 + 0.70px + 1.00py; |
| 165 |
z3= z0 + 0.70px + 1.60py; |
| 166 |
z4= z0 + 0.10px + 2.10py; |
| 167 |
z5= z0 - 0.20px + 1.90py; |
| 168 |
z6= z0 - 0.60px + 0.50py; |
| 169 |
z7= z0 - 0.60px + 0.10py; |
| 170 |
z8= z0 - 0.50px + 0.00py; |
| 171 |
forsuffixes i=0,1,2,3,4,5,6,7,8: |
| 172 |
z[i].. |
| 173 |
endfor cycle |
| 174 |
endgroup |
| 175 |
enddef; |
| 176 |
|
| 177 |
def EyePath (expr p,s) = |
| 178 |
begingroup |
| 179 |
save z; pair z[]; |
| 180 |
|
| 181 |
z0 + (0,s) = p; |
| 182 |
pair px,py; |
| 183 |
py= p - z0; |
| 184 |
px= py rotated -90; |
| 185 |
|
| 186 |
z1= z0 + 1.00px + 1.00py; |
| 187 |
|
| 188 |
z0{0,1} .. {1,0} z1 & z1 {0,-1} .. {-1,0}z0 & cycle |
| 189 |
endgroup |
| 190 |
enddef; |
| 191 |
|
| 192 |
def EyeBrowPath (expr p,s) = |
| 193 |
begingroup |
| 194 |
save z; pair z[]; |
| 195 |
|
| 196 |
z0 + (0,s) = p; |
| 197 |
pair px,py; |
| 198 |
py= p - z0; |
| 199 |
px= py rotated -90; |
| 200 |
|
| 201 |
z1= z0 - 0.74px - 0.74py; |
| 202 |
z2= z0 + 1.74px + 1.74py; |
| 203 |
|
| 204 |
z1{0,1} .. {1,0}z2 |
| 205 |
endgroup |
| 206 |
enddef; |
| 207 |
|
| 208 |
def MakeWhiteKnight = |
| 209 |
clearit; |
| 210 |
pickup chess_pen; |
| 211 |
draw Foot; |
| 212 |
draw RightEar; |
| 213 |
draw EarUnderEar; |
| 214 |
draw LeftEar & Bless & MouthNose & UnderMouth; |
| 215 |
draw ToFoot; |
| 216 |
draw EyePath(z26,.025qs); |
| 217 |
filldraw DefineNosePath(z25,.015qs); |
| 218 |
pickup chess_pen xscaled 2 rotated -10; |
| 219 |
draw ShortenEnd(Nack,thin); |
| 220 |
pickup chess_pen scaled 0.6; |
| 221 |
draw EyeBrowPath(z26,.030qs); |
| 222 |
WhiteMan:= currentpicture; |
| 223 |
enddef; |
| 224 |
|
| 225 |
def MakeBlackKnight = |
| 226 |
clearit; |
| 227 |
pickup chess_pen; |
| 228 |
|
| 229 |
filldraw KnightShape; |
| 230 |
cullit; |
| 231 |
unfilldraw DefineNosePath(z25,.015qs); |
| 232 |
undraw EyePath(z26,.025qs); |
| 233 |
undraw ParallelPath(EarUnderEar,1.2thin) rotatedaround(z6,-20); |
| 234 |
pickup chess_pen xscaled 2 rotated -20; |
| 235 |
undraw ShortenPath(xyParallelPath(Nack,1.5thin,thin),thin); |
| 236 |
pickup chess_pen scaled .6; |
| 237 |
undraw subpath (3,3.5) of UnderMouth; |
| 238 |
undraw EyeBrowPath(z26,.030qs); |
| 239 |
undraw subpath (2.5,3) of MouthNose; |
| 240 |
BlackMan:= currentpicture; |
| 241 |
enddef; |
| 242 |
|
| 243 |
def MakeKnightSpace = |
| 244 |
clearit; |
| 245 |
pickup frame_pen; |
| 246 |
filldraw KnightShape; |
| 247 |
cullit; |
| 248 |
OuterShape:= currentpicture; |
| 249 |
enddef; |
| 250 |
|
| 251 |
DefineKnightPath; |
| 252 |
%DefineNosePath(z25,.2qs); |
| 253 |
|
| 254 |
MakeWhiteKnight; |
| 255 |
MakeBlackKnight; |
| 256 |
MakeNeutral(WhiteMan,BlackMan); |
| 257 |
MakeKnightSpace; |
| 258 |
|
| 259 |
%=========================================================== |
| 260 |
% this one for testing |
| 261 |
%beginchar(Knight+Black+OnBlack, qs#, qs#, 0); |
| 262 |
% "White knight on black field"; |
| 263 |
% MakeBlackField; |
| 264 |
% cullit; |
| 265 |
% currentpicture:= currentpicture - OuterShape; |
| 266 |
% cullit; |
| 267 |
% currentpicture:= currentpicture + BlackMan; |
| 268 |
%endchar; |
| 269 |
%endinput |
| 270 |
%=========================================================== |
| 271 |
|
| 272 |
beginchar(Knight+White+OnWhite, qs#, qs#, 0); |
| 273 |
"White knight on white field"; |
| 274 |
currentpicture:= WhiteMan; |
| 275 |
% labels(z0,z1l,z1,z1r,z2l,z2,z2r); |
| 276 |
% labels(z3l,z3,z3l,z4,z5,z6l,z6r); |
| 277 |
% labels(z7l,z7,z7r,z8); |
| 278 |
endchar; |
| 279 |
|
| 280 |
beginchar(Knight+White+OnWhite+LeftTurned, qs#, qs#, 0); |
| 281 |
"White knight turned to the left on white field"; |
| 282 |
currentpicture:= TurnLeft(WhiteMan); |
| 283 |
endchar; |
| 284 |
|
| 285 |
beginchar(Knight+White+OnWhite+RightTurned, qs#, qs#, 0); |
| 286 |
"White knight turned to the right on white field"; |
| 287 |
currentpicture:= TurnRight(WhiteMan); |
| 288 |
endchar; |
| 289 |
|
| 290 |
beginchar(Knight+White+OnWhite+UpSideDown, qs#, qs#, 0); |
| 291 |
"White knight turned upsidedown on white field"; |
| 292 |
currentpicture:= TurnUpSideDown(WhiteMan); |
| 293 |
endchar; |
| 294 |
|
| 295 |
%=========================================================== |
| 296 |
|
| 297 |
beginchar(Knight+White+OnBlack, qs#, qs#, 0); |
| 298 |
"White knight on black field"; |
| 299 |
MakeBlackField; |
| 300 |
cullit; |
| 301 |
currentpicture:= currentpicture - OuterShape; |
| 302 |
cullit; |
| 303 |
currentpicture:= currentpicture + WhiteMan; |
| 304 |
endchar; |
| 305 |
|
| 306 |
beginchar(Knight+White+OnBlack+LeftTurned, qs#, qs#, 0); |
| 307 |
"White knight turned to the left on black field"; |
| 308 |
MakeBlackField; |
| 309 |
cullit; |
| 310 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 311 |
cullit; |
| 312 |
currentpicture:= currentpicture + TurnLeft(WhiteMan); |
| 313 |
endchar; |
| 314 |
|
| 315 |
beginchar(Knight+White+OnBlack+RightTurned, qs#, qs#, 0); |
| 316 |
"White knight turned to the right on black field"; |
| 317 |
MakeBlackField; |
| 318 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 319 |
cullit; |
| 320 |
currentpicture:= currentpicture + TurnRight(WhiteMan); |
| 321 |
endchar; |
| 322 |
|
| 323 |
beginchar(Knight+White+OnBlack+UpSideDown, qs#, qs#, 0); |
| 324 |
"White knight turned upsidedown on black field"; |
| 325 |
MakeBlackField; |
| 326 |
cullit; |
| 327 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 328 |
cullit; |
| 329 |
currentpicture:= currentpicture + TurnUpSideDown(WhiteMan); |
| 330 |
endchar; |
| 331 |
|
| 332 |
%=========================================================== |
| 333 |
|
| 334 |
beginchar(Knight+Neutral+OnWhite, qs#, qs#, 0); |
| 335 |
"Neutral knight on white field"; |
| 336 |
currentpicture:= NeutralMan; |
| 337 |
endchar; |
| 338 |
|
| 339 |
beginchar(Knight+Neutral+OnWhite+LeftTurned, qs#, qs#, 0); |
| 340 |
"Neutral knight turned to the left on white field"; |
| 341 |
currentpicture:= TurnLeft(NeutralMan); |
| 342 |
endchar; |
| 343 |
|
| 344 |
beginchar(Knight+Neutral+OnWhite+RightTurned, qs#, qs#, 0); |
| 345 |
"Neutral knight turned to the right on white field"; |
| 346 |
currentpicture:= TurnRight(NeutralMan); |
| 347 |
endchar; |
| 348 |
|
| 349 |
beginchar(Knight+Neutral+OnWhite+UpSideDown, qs#, qs#, 0); |
| 350 |
"Neutral knight turned upsidedown on white field"; |
| 351 |
currentpicture:= TurnUpSideDown(NeutralMan); |
| 352 |
endchar; |
| 353 |
|
| 354 |
%=========================================================== |
| 355 |
|
| 356 |
beginchar(Knight+Neutral+OnBlack, qs#, qs#, 0); |
| 357 |
"Neutral knight on black field"; |
| 358 |
MakeBlackField; |
| 359 |
cullit; |
| 360 |
currentpicture:= currentpicture - OuterShape; |
| 361 |
cullit; |
| 362 |
currentpicture:= currentpicture + NeutralMan; |
| 363 |
endchar; |
| 364 |
|
| 365 |
beginchar(Knight+Neutral+OnBlack+LeftTurned, qs#, qs#, 0); |
| 366 |
"Neutral knight turned to the left on black field"; |
| 367 |
MakeBlackField; |
| 368 |
cullit; |
| 369 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 370 |
cullit; |
| 371 |
currentpicture:= currentpicture + TurnLeft(NeutralMan); |
| 372 |
endchar; |
| 373 |
|
| 374 |
beginchar(Knight+Neutral+OnBlack+RightTurned, qs#, qs#, 0); |
| 375 |
"Neutral knight turned to the right on black field"; |
| 376 |
MakeBlackField; |
| 377 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 378 |
cullit; |
| 379 |
currentpicture:= currentpicture + TurnRight(NeutralMan); |
| 380 |
endchar; |
| 381 |
|
| 382 |
beginchar(Knight+Neutral+OnBlack+UpSideDown, qs#, qs#, 0); |
| 383 |
"Neutral knight turned upsidedown on black field"; |
| 384 |
MakeBlackField; |
| 385 |
cullit; |
| 386 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 387 |
cullit; |
| 388 |
currentpicture:= currentpicture + TurnUpSideDown(NeutralMan); |
| 389 |
endchar; |
| 390 |
|
| 391 |
%=========================================================== |
| 392 |
|
| 393 |
beginchar(Knight+Black+OnWhite, qs#, qs#, 0); |
| 394 |
"Black knight on white field"; |
| 395 |
currentpicture:= BlackMan; |
| 396 |
endchar; |
| 397 |
|
| 398 |
beginchar(Knight+Black+OnWhite+LeftTurned, qs#, qs#, 0); |
| 399 |
"Black knight turned to the left on white field"; |
| 400 |
currentpicture:= TurnLeft(BlackMan); |
| 401 |
endchar; |
| 402 |
|
| 403 |
beginchar(Knight+Black+OnWhite+RightTurned, qs#, qs#, 0); |
| 404 |
"Black knight turned to the right on white field"; |
| 405 |
currentpicture:= TurnRight(BlackMan); |
| 406 |
endchar; |
| 407 |
|
| 408 |
beginchar(Knight+Black+OnWhite+UpSideDown, qs#, qs#, 0); |
| 409 |
"Black knight turned upsidedown on white field"; |
| 410 |
currentpicture:= TurnUpSideDown(BlackMan); |
| 411 |
endchar; |
| 412 |
|
| 413 |
%=========================================================== |
| 414 |
|
| 415 |
beginchar(Knight+Black+OnBlack, qs#, qs#, 0); |
| 416 |
"Black knight on black field"; |
| 417 |
MakeBlackField; |
| 418 |
cullit; |
| 419 |
currentpicture:= currentpicture - OuterShape; |
| 420 |
cullit; |
| 421 |
currentpicture:= currentpicture + BlackMan; |
| 422 |
endchar; |
| 423 |
|
| 424 |
beginchar(Knight+Black+OnBlack+LeftTurned, qs#, qs#, 0); |
| 425 |
"Black knight turned to the left on black field"; |
| 426 |
MakeBlackField; |
| 427 |
cullit; |
| 428 |
currentpicture:= currentpicture - TurnLeft(OuterShape); |
| 429 |
cullit; |
| 430 |
currentpicture:= currentpicture + TurnLeft(BlackMan); |
| 431 |
endchar; |
| 432 |
|
| 433 |
beginchar(Knight+Black+OnBlack+RightTurned, qs#, qs#, 0); |
| 434 |
"Black knight turned to the right on black field"; |
| 435 |
MakeBlackField; |
| 436 |
currentpicture:= currentpicture - TurnRight(OuterShape); |
| 437 |
cullit; |
| 438 |
currentpicture:= currentpicture + TurnRight(BlackMan); |
| 439 |
endchar; |
| 440 |
|
| 441 |
beginchar(Knight+Black+OnBlack+UpSideDown, qs#, qs#, 0); |
| 442 |
"Black knight turned upsidedown on black field"; |
| 443 |
MakeBlackField; |
| 444 |
cullit; |
| 445 |
currentpicture:= currentpicture - TurnUpSideDown(OuterShape); |
| 446 |
cullit; |
| 447 |
currentpicture:= currentpicture + TurnUpSideDown(BlackMan); |
| 448 |
endchar; |
| 449 |
|
| 450 |
endinput |