1%% options 2 3copyright owner = Dirk Krause 4copyright year = 2017-xxxx 5SPDX-License-Identifier: BSD-3-Clause 6 7 8%% module 9 10#include "dk4conf.h" 11 12#include <stdio.h> 13 14#ifndef DK4GRA_H_INCLUDED 15#include <libdk4gra/dk4gra.h> 16#endif 17 18#ifndef GRA_H_INCLUDED 19#include <libdk4gra/gra.h> 20#endif 21 22#if DK4_HAVE_ASSERT_H 23#ifndef ASSERT_H_INCLUDED 24#include <assert.h> 25#define ASSERT_H_INCLUDED 1 26#endif 27#endif 28 29 30/** Pattern procedure. 31*/ 32static const char * const p00[] = { 33$!string-table 34/ThirtyLeft % xs xe ys ye dy 35{ 36 3 index 5 index sub 3.0 sqrt div % xs xe ys ye dy ydiff 37 3 index % xs xe ys ye dy ydiff y 38 { 39 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 40 5 index 1 index % xs xe ys ye dy ydiff y xe y 41 8 index 1 index 5 index add % xs xe ys ye dy ydiff y xe y xs y2 42 newpath moveto % xs xe ys ye dy ydiff y xe y 43 lineto stroke % xs xe ys ye dy ydiff y 44 2 index add % xs xe ys ye dy ydiff y 45 } 46 loop % xs xe ys ye dy ydiff y 47 pop pop pop pop pop pop pop % -- 48} bind def 49$!end 50}; 51 52 53 54/** Pattern procedure. 55*/ 56static const char * const p01[] = { 57$!string-table 58/ThirtyRight % xs xe ys ye dy 59{ 60 3 index 5 index sub 3.0 sqrt div % xs xe ys ye dy ydiff 61 3 index % xs xe ys ye dy ydiff y 62 { 63 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 64 6 index 1 index % xs xe ys ye dy ydiff y xs y 65 7 index 1 index % xs xe ys ye dy ydiff y xs y xe y 66 5 index add % xs xe ys ye dy ydiff y xs y xe y2 67 newpath moveto % xs xe ys ye dy ydiff y xs y 68 lineto stroke % xs xe ys ye dy ydiff y 69 2 index add % xs xe ys ye dy ydiff y 70 } 71 loop % xs xe ys ye dy ydiff y 72 pop pop pop pop pop pop pop % -- 73} bind def 74$!end 75}; 76 77 78 79/** Pattern procedure. 80*/ 81static const char * const p02[] = { 82$!string-table 83/ThirtyHatch % xs xe ys ye dy 84{ 85 3 index 5 index sub 3.0 sqrt div % xs xe ys ye dy ydiff 86 3 index % xs xe ys ye dy ydiff y 87 { 88 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 89 6 index 1 index % xs xe ys ye dy ydiff y xs y 90 7 index 1 index % xs xe ys ye dy ydiff y xs y xe y 91 5 index add % xs xe ys ye dy ydiff y xs y xe y2 92 newpath moveto % xs xe ys ye dy ydiff y xs y 93 lineto stroke % xs xe ys ye dy ydiff y 94 2 index add % xs xe ys ye dy ydiff y 95 } 96 loop % xs xe ys ye dy ydiff y 97 pop pop % xs xe ys ye dy 98 3 index 5 index sub 3.0 sqrt div % xs xe ys ye dy ydiff 99 3 index % xs xe ys ye dy ydiff y 100 { 101 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 102 5 index 1 index % xs xe ys ye dy ydiff y xe y 103 8 index 1 index 5 index add % xs xe ys ye dy ydiff y xe y xs y2 104 newpath moveto % xs xe ys ye dy ydiff y xe y 105 lineto stroke % xs xe ys ye dy ydiff y 106 2 index add % xs xe ys ye dy ydiff y 107 } 108 loop % xs xe ys ye dy ydiff y 109 pop pop pop pop pop pop pop % -- 110} bind def 111$!end 112}; 113 114 115 116/** Pattern procedure. 117*/ 118static const char * const p03[] = { 119$!string-table 120/FourtyFiveLeft % xs xe ys ye dy 121{ 122 3 index 5 index sub % xs xe ys ye dy ydiff 123 3 index % xs xe ys ye dy ydiff y 124 { 125 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 126 5 index 1 index % xs xe ys ye dy ydiff y xe y 127 8 index 1 index 5 index add % xs xe ys ye dy ydiff y xe y xs y2 128 newpath moveto % xs xe ys ye dy ydiff y xe y 129 lineto stroke % xs xe ys ye dy ydiff y 130 2 index add % xs xe ys ye dy ydiff y 131 } 132 loop % xs xe ys ye dy ydiff y 133 pop pop pop pop pop pop pop % -- 134} bind def 135$!end 136}; 137 138 139 140/** Pattern procedure. 141*/ 142static const char * const p04[] = { 143$!string-table 144/FourtyFiveRight % xs xe ys ye dy 145{ 146 3 index 5 index sub % xs xe ys ye dy ydiff 147 3 index % xs xe ys ye dy ydiff y 148 { 149 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 150 6 index 1 index % xs xe ys ye dy ydiff y xs y 151 7 index 1 index % xs xe ys ye dy ydiff y xs y xe y 152 5 index add % xs xe ys ye dy ydiff y xs y xe y2 153 newpath moveto % xs xe ys ye dy ydiff y xs y 154 lineto stroke % xs xe ys ye dy ydiff y 155 2 index add % xs xe ys ye dy ydiff y 156 } 157 loop % xs xe ys ye dy ydiff y 158 pop pop pop pop pop pop pop % -- 159} bind def 160$!end 161}; 162 163 164 165/** Pattern procedure. 166*/ 167static const char * const p05[] = { 168$!string-table 169/FourtyFiveHatch % xs xe ys ye dy 170{ 171 3 index 5 index sub % xs xe ys ye dy ydiff 172 3 index % xs xe ys ye dy ydiff y 173 { 174 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 175 5 index 1 index % xs xe ys ye dy ydiff y xe y 176 8 index 1 index 5 index add % xs xe ys ye dy ydiff y xe y xs y2 177 newpath moveto % xs xe ys ye dy ydiff y xe y 178 lineto stroke % xs xe ys ye dy ydiff y 179 2 index add % xs xe ys ye dy ydiff y 180 } 181 loop % xs xe ys ye dy ydiff y 182 pop pop % xs xe ys ye dy 183 3 index 5 index sub % xs xe ys ye dy ydiff 184 3 index % xs xe ys ye dy ydiff y 185 { 186 dup 4 index gt {exit} if % xs xe ys ye dy ydiff y 187 6 index 1 index % xs xe ys ye dy ydiff y xs y 188 7 index 1 index % xs xe ys ye dy ydiff y xs y xe y 189 5 index add % xs xe ys ye dy ydiff y xs y xe y2 190 newpath moveto % xs xe ys ye dy ydiff y xs y 191 lineto stroke % xs xe ys ye dy ydiff y 192 2 index add % xs xe ys ye dy ydiff y 193 } 194 loop % xs xe ys ye dy ydiff y 195 pop pop pop pop pop pop pop % -- 196} bind def 197$!end 198}; 199 200 201 202/** Pattern procedure. 203*/ 204static const char * const p06[] = { 205$!string-table 206/HorizontalBricks % xs xe ys ye dy 207{ 208 2 index 0 % xs xe ys ye dy y nr 209 { 210 1 index % xs xe ys ye dy y nr y 211 4 index % xs xe ys ye dy y nr y ye 212 gt {exit} if % xs xe ys ye dy y nr 213 6 index % xs xe ys ye dy y nr xs 214 2 index % xs xe ys ye dy y nr xs y 215 7 index % xs xe ys ye dy y nr xs y xe 216 1 index % xs xe ys ye dy y nr xs y xe y 217 newpath moveto lineto stroke % xs xe ys ye dy y nr 218 6 index % xs xe ys ye dy y nr x 219 1 index 0 % xs xe ys ye dy y nr x nr 0 220 gt {3 index add} if % xs xe ys ye dy y nr x 221 { 222 dup 7 index % xs xe ys ye dy y nr x x xe 223 gt {exit} if % xs xe ys ye dy y nr x 224 dup 3 index % xs xe ys ye dy y nr x x y 225 1 index 1 index % xs xe ys ye dy y nr x x y x y 226 7 index add % xs xe ys ye dy y nr x x y x y 227 newpath moveto lineto stroke % xs xe ys ye dy y nr x 228 3 index 2.0 mul add % xs xe ys ye dy y nr x 229 } 230 loop % xs xe ys ye dy y nr x 231 pop % xs xe ys ye dy y nr 232 1 add % xs xe ys ye dy y nr 233 dup % xs xe ys ye dy y nr nr 234 1 gt {pop 0} if % xs xe ys ye dy y nr 235 exch 2 index add exch % xs xe ys ye dy y nr 236 } 237 loop % xs xe ys ye dy y nr 238 pop pop pop pop pop pop pop % -- 239} bind def 240$!end 241}; 242 243 244 245/** Pattern procedure. 246*/ 247static const char * const p07[] = { 248$!string-table 249/VerticalBricks % xs xe ys ye dx 250{ 251 4 index 0 % xs xe ys ye dx x nr 252 { 253 1 index 6 index % xs xe ys ye dx x nr x xe 254 gt {exit} if % xs xe ys ye dx x nr 255 1 index 5 index % xs xe ys ye dx x nr x ys 256 1 index 6 index % xs xe ys ye dx x nr x ys x ye 257 newpath moveto lineto stroke % xs xe ys ye dx x nr 258 4 index 1 index 0 % xs xe ys ye dx x nr y nr 0 259 gt {3 index add} if % xs xe ys ye dx x nr y 260 { 261 dup 5 index % xs xe ys ye dx x nr y y ye 262 gt {exit} if % xs xe ys ye dx x nr y 263 2 index 1 index % xs xe ys ye dx x nr y x y 264 dup 2 index % xs xe ys ye dx x nr y x y y x 265 7 index add exch % xs xe ys ye dx x nr y x y x y 266 newpath moveto lineto stroke % xs xe ys ye dx x nr y 267 3 index 2.0 mul add % xs xe ys ye dx x nr y 268 } 269 loop % xs xe ys ye dx x nr y 270 pop % xs xe ys ye dx x nr 271 exch 2 index add exch % xs xe ys ye dx x nr 272 1 add % xs xe ys ye dx x nr 273 dup 1 % xs xe ys ye dx x nr nr 1 274 gt {pop 0} if % xs xe ys ye dx x nr 275 } 276 loop % xs xe ys ye dx x nr 277 pop pop pop pop pop pop pop % -- 278} bind def 279$!end 280}; 281 282 283 284/** Pattern procedure. 285*/ 286static const char * const p08[] = { 287$!string-table 288/HorizontalLines % xs xe ys ye dy 289{ 290 2 index % xs xe ys ye dy y 291 { 292 dup 3 index gt {exit} if % xs xe ys ye dy y 293 4 index 1 index % xs xe ys ye dy y xe y 294 7 index 1 index % xs xe ys ye dy y xe y xs y 295 newpath moveto % xs xe ys ye dy y xe y 296 lineto stroke % xs xe ys ye dy y 297 1 index add % xs xe ys ye dy y 298 } 299 loop % xs xe ys ye dy y 300 pop pop pop pop pop pop % -- 301} bind def 302$!end 303}; 304 305 306 307/** Pattern procedure. 308*/ 309static const char * const p09[] = { 310$!string-table 311/VerticalLines % xs xe ys ye dx 312{ 313 4 index % xs xe ys ye dx x 314 { 315 dup 5 index gt {exit} if % xs xe ys ye dx x 316 dup 3 index % xs xe ys ye dx x x ye 317 1 index 6 index % xs xe ys ye dx x x ye x ys 318 newpath moveto % xs xe ys ye dx x x ye 319 lineto stroke % xs xe ys ye dx x 320 1 index add % xs xe ys ye dx x 321 } 322 loop % xs xe ys ye dx x 323 pop pop pop pop pop pop % -- 324} bind def 325$!end 326}; 327 328 329 330/** Pattern procedure. 331*/ 332static const char * const p10[] = { 333$!string-table 334/CrossHatch % xs xe ys ye dx 335{ 336 4 index % xs xe ys ye dx x 337 { 338 dup 5 index gt {exit} if % xs xe ys ye dx x 339 dup 3 index % xs xe ys ye dx x x ye 340 1 index 6 index % xs xe ys ye dx x x ye x ys 341 newpath moveto % xs xe ys ye dx x x ye 342 lineto stroke % xs xe ys ye dx x 343 1 index add % xs xe ys ye dx x 344 } 345 loop % xs xe ys ye dx x 346 pop % xs xe ys ye dy 347 2 index % xs xe ys ye dy y 348 { 349 dup 3 index gt {exit} if % xs xe ys ye dy y 350 4 index 1 index % xs xe ys ye dy y xe y 351 7 index 1 index % xs xe ys ye dy y xe y xs y 352 newpath moveto % xs xe ys ye dy y xe y 353 lineto stroke % xs xe ys ye dy y 354 1 index add % xs xe ys ye dy y 355 } 356 loop % xs xe ys ye dy y 357 pop pop pop pop pop pop % -- 358} bind def 359$!end 360}; 361 362 363 364/** Pattern procedure. 365*/ 366static const char * const p11[] = { 367$!string-table 368/HorizontalShinglesLeft % xs xe ys ye dy 369{ 370 2 index % xs xe ys ye dy y 371 { 372 dup 3 index gt {exit} if % xs xe ys ye dy y 373 4 index 1 index % xs xe ys ye dy y xe y 374 7 index 1 index % xs xe ys ye dy y xe y xs y 375 newpath moveto % xs xe ys ye dy y xe y 376 lineto stroke % xs xe ys ye dy y 377 1 index add % xs xe ys ye dy y 378 } 379 loop % xs xe ys ye dy y 380 pop % xs xe ys ye dy 381 2 index 0 % xs xe ys ye dy y nr 382 { 383 1 index 4 index gt {exit} if % xs xe ys ye dy y nr 384 6 index % xs xe ys ye dy y nr x 385 1 index 2 gt 386 { 3 index 0.5 mul add } 387 { 388 1 index 1 gt 389 { 3 index add } 390 { 391 1 index 0 gt 392 { 3 index 1.5 mul add } 393 if 394 } 395 ifelse 396 } 397 ifelse 398 { 399 dup 7 index gt {exit} if % xs xe ys ye dy y nr x 400 dup 4 index 0.5 mul add % xs xe ys ye dy y nr x x2 401 3 index 5 index add % xs xe ys ye dy y nr x x2 y2 402 2 index 5 index newpath moveto % xs xe ys ye dy y nr x x2 y2 403 lineto stroke % xs xe ys ye dy y nr x 404 3 index 2.0 mul add % xs xe ys ye dy y nr x 405 } 406 loop pop % xs xe ys ye dy y nr 407 exch 2 index add exch % xs xe ys ye dy y nr 408 1 add dup 3 gt {pop 0} if % xs xe ys ye dy y nr 409 } 410 loop % xs xe ys ye dy y nr 411 pop pop pop pop pop pop pop 412} bind def 413$!end 414}; 415 416 417 418/** Pattern procedure. 419*/ 420static const char * const p12[] = { 421$!string-table 422/HorizontalShinglesRight % xs xe ys ye dy 423{ 424 2 index % xs xe ys ye dy y 425 { 426 dup 3 index gt {exit} if % xs xe ys ye dy y 427 4 index 1 index % xs xe ys ye dy y xe y 428 7 index 1 index % xs xe ys ye dy y xe y xs y 429 newpath moveto % xs xe ys ye dy y xe y 430 lineto stroke % xs xe ys ye dy y 431 1 index add % xs xe ys ye dy y 432 } 433 loop % xs xe ys ye dy y 434 pop % xs xe ys ye dy 435 2 index 0 % xs xe ys ye dy y nr 436 { 437 1 index 4 index gt {exit} if % xs xe ys ye dy y nr 438 6 index % xs xe ys ye dy y nr x 439 1 index 4 index 0.5 mul mul add % xs xe ys ye dy y nr x 440 { 441 dup 7 index gt {exit} if % xs xe ys ye dy y nr x 442 dup 3 index 5 index add % xs xe ys ye dy y nr x x y2 443 1 index 6 index 0.5 mul add % xs xe ys ye dy y nr x x y2 x2 444 5 index newpath moveto lineto % xs xe ys ye dy y nr x 445 stroke 446 3 index 2.0 mul add % xs xe ys ye dy y nr x 447 } 448 loop pop % xs xe ys ye dy y nr 449 exch 2 index add exch % xs xe ys ye dy y nr 450 1 add dup 3 gt {pop 0} if % xs xe ys ye dy y nr 451 } 452 loop % xs xe ys ye dy y nr 453 pop pop pop pop pop pop pop 454} bind def 455$!end 456}; 457 458 459 460/** Pattern procedure. 461*/ 462static const char * const p13[] = { 463$!string-table 464/VerticalShinglesLeft % xs xe ys ye dx 465{ 466 4 index % xs xe ys ye dx x 467 { 468 dup 5 index gt {exit} if % xs xe ys ye dx x 469 dup 3 index % xs xe ys ye dx x x ye 470 1 index 6 index % xs xe ys ye dx x x ye x ys 471 newpath moveto % xs xe ys ye dx x x ye 472 lineto stroke % xs xe ys ye dx x 473 1 index add % xs xe ys ye dx x 474 } 475 loop % xs xe ys ye dx x 476 pop % xs xe ys ye dx 477 4 index 0 % xs xe ys ye dx x nr 478 { 479 1 index 6 index gt {exit} if % xs xe ys ye dx x nr 480 4 index % xs xe ys ye dx x nr y 481 3 index 2 index 0.5 mul mul add % xs xe ys ye dx x nr y 482 { 483 dup 5 index gt {exit} if % xs xe ys ye dx x nr y 484 2 index 1 index % xs xe ys ye dx x nr y x y 485 5 index 0.5 mul add % xs xe ys ye dx x nr y x y2 486 1 index 6 index add 3 index % xs xe ys ye dx x nr y x y2 x2 y 487 newpath moveto lineto stroke % xs xe ys ye dx x nr y 488 3 index 2.0 mul add % xs xe ys ye dx x nr y 489 } 490 loop pop % xs xe ys ye dx x nr 491 exch 2 index add exch % xs xe ys ye dx x nr 492 1 add dup 3 gt {pop 0} if % xs xe ys ye dx x nr 493 } 494 loop % xs xe ys ye dx x nr 495 pop pop pop pop pop pop pop % -- 496} bind def 497$!end 498}; 499 500 501 502/** Pattern procedure. 503*/ 504static const char * const p14[] = { 505$!string-table 506/VerticalShinglesRight % xs xe ys ye dx 507{ 508 4 index % xs xe ys ye dx x 509 { 510 dup 5 index gt {exit} if % xs xe ys ye dx x 511 dup 3 index % xs xe ys ye dx x x ye 512 1 index 6 index % xs xe ys ye dx x x ye x ys 513 newpath moveto % xs xe ys ye dx x x ye 514 lineto stroke % xs xe ys ye dx x 515 1 index add % xs xe ys ye dx x 516 } 517 loop % xs xe ys ye dx x 518 pop % xs xe ys ye dx 519 4 index 0 % xs xe ys ye dx x nr 520 { 521 1 index 6 index gt {exit} if % xs xe ys ye dx x nr 522 4 index % xs xe ys ye dx x nr y 523 1 index 2 gt 524 { 3 index 0.5 mul add } 525 { 526 1 index 1 gt 527 { 3 index add } 528 { 529 1 index 0 gt 530 { 3 index 1.5 mul add } 531 if 532 } 533 ifelse 534 } 535 ifelse 536 { 537 dup 5 index gt {exit} if % xs xe ys ye dx x nr y 538 2 index 1 index % xs xe ys ye dx x nr y x y 539 1 index 6 index add % xs xe ys ye dx x nr y x y x2 540 1 index 7 index 0.5 mul add % xs xe ys ye dx x nr y x y x2 y2 541 newpath moveto lineto stroke % xs xe ys ye dx x nr y 542 3 index 2.0 mul add % xs xe ys ye dx x nr y 543 } 544 loop pop % xs xe ys ye dx x nr 545 exch 2 index add exch % xs xe ys ye dx x nr 546 1 add dup 3 gt {pop 0} if % xs xe ys ye dx x nr 547 } 548 loop % xs xe ys ye dx x nr 549 pop pop pop pop pop pop pop % -- 550} bind def 551$!end 552}; 553 554 555 556/** Pattern procedure. 557*/ 558static const char * const p15[] = { 559$!string-table 560/FishScales % xs xe ys ye dx dy r a1 a2 561{ 562 6 index 0 % xs xe ys ye dx dy r a1 a2 y nr 563 { 564 1 index 8 index gt {exit} if % xs xe ys ye dx dy r a1 a2 y nr 565 10 index % xs xe ys ye dx dy r a1 a2 y nr x 566 1 index 0 gt 567 { 7 index 0.5 mul add } 568 if 569 { 570 dup 11 index gt {exit} if % xs xe ys ye dx dy r a1 a2 y nr x 571 dup 3 index 8 index add % xs xe ys ye dx dy r a1 a2 y nr x x y+dy 572 newpath moveto % xs xe ys ye dx dy r a1 a2 y nr x 573 dup 8 index 0.5 mul add % xs xe ys ye dx dy r a1 a2 y nr x xm 574 3 index 7 index add % xs xe ys ye dx dy r a1 a2 y nr x xm ym 575 7 index 7 index 7 index % xs xe ys ye dx dy r a1 a2 y nr x xm ym r a1 a2 576 arc stroke % xs xe ys ye dx dy r a1 a2 y nr x 577 7 index add % xs xe ys ye dx dy r a1 a2 y nr x 578 } 579 loop pop % xs xe ys ye dx dy r a1 a2 y nr 580 exch 5 index add exch % xs xe ys ye dx dy r a1 a2 y nr 581 1 add dup 1 gt {pop 0} if % xs xe ys ye dx dy r a1 a2 y nr 582 } 583 loop % xs xe ys ye dx dy r a1 a2 y nr 584 pop pop pop pop pop pop pop pop pop pop pop 585} bind def 586$!end 587}; 588 589 590 591/** Pattern procedure. 592*/ 593static const char * const p16[] = { 594$!string-table 595/SmallFishScales % xs xe ys ye dx dy r a1 a2 596{ 597 6 index 0 % xs xe ys ye dx dy r a1 a2 y nr 598 { 599 1 index 8 index gt {exit} if % xs xe ys ye dx dy r a1 a2 y nr 600 10 index % xs xe ys ye dx dy r a1 a2 y nr x 601 1 index 0 gt 602 { 7 index 0.5 mul add } 603 if 604 { 605 dup 11 index gt {exit} if % xs xe ys ye dx dy r a1 a2 y nr x 606 dup 3 index 8 index add % xs xe ys ye dx dy r a1 a2 y nr x x y+dy 607 newpath moveto % xs xe ys ye dx dy r a1 a2 y nr x 608 dup 8 index 0.5 mul add % xs xe ys ye dx dy r a1 a2 y nr x xm 609 3 index 7 index add % xs xe ys ye dx dy r a1 a2 y nr x xm ym 610 7 index 7 index 7 index % xs xe ys ye dx dy r a1 a2 y nr x xm ym r a1 a2 611 arc stroke % xs xe ys ye dx dy r a1 a2 y nr x 612 7 index add % xs xe ys ye dx dy r a1 a2 y nr x 613 } 614 loop pop % xs xe ys ye dx dy r a1 a2 y nr 615 exch 5 index add exch % xs xe ys ye dx dy r a1 a2 y nr 616 1 add dup 1 gt {pop 0} if % xs xe ys ye dx dy r a1 a2 y nr 617 } 618 loop % xs xe ys ye dx dy r a1 a2 y nr 619 pop pop pop pop pop pop pop pop pop pop pop 620} bind def 621$!end 622}; 623 624 625 626/** Pattern procedure. 627*/ 628static const char * const p17[] = { 629$!string-table 630/Circles % xs xe ys ye r 631{ 632 2 index % xs xe ys ye r y 633 { 634 dup 3 index gt {exit} if 635 5 index % xs xe ys ye r y x 636 { 637 dup 6 index gt {exit} if 638 dup 3 index add % xs xe ys ye r y x xm 639 2 index 4 index add % xs xe ys ye r y x xm ym 640 4 index 0 360 % xs xe ys ye r y x xm ym r a1 a2 641 4 index 3 index add % xs xe ys ye r y x xm ym r a1 a2 xr 642 4 index % xs xe ys ye r y x xm ym r a1 a2 xr yr 643 newpath moveto arc 644 closepath stroke % xs xe ys ye r y x 645 2 index dup add add 646 } 647 loop pop 648 1 index dup add add % xs xe ys ye r y 649 } 650 loop % xs xe ys ye r y 651 pop pop pop pop pop pop % -- 652} bind def 653$!end 654}; 655 656 657 658/** Pattern procedure. 659*/ 660static const char * const p18[] = { 661$!string-table 662/Hexagons % xs xe ys ye dx dy 663{ 664 1 index 3.0 div % xs xe ys ye dx dy r 665 4 index % xs xe ys ye dx dy r y 666 { 667 dup 5 index gt {exit} if 668 7 index % xs xe ys ye dx dy r y x 669 { 670 dup 8 index gt {exit} if 671 newpath 672 dup 3 index 3.0 mul add % xs xe ys ye dx dy r y x x0 673 2 index 5 index 0.5 mul add % xs xe ys ye dx dy r y x x0 y0 674 moveto % xs xe ys ye dx dy r y x 675 dup 3 index 2.0 mul add % xs xe ys ye dx dy r y x x1 676 2 index 5 index 0.5 mul add % xs xe ys ye dx dy r y x x1 y1 677 lineto % xs xe ys ye dx dy r y x 678 dup 3 index 1.5 mul add % xs xe ys ye dx dy r y x x2 679 2 index 5 index add % xs xe ys ye dx dy r y x x2 y2 680 lineto % xs xe ys ye dx dy r y x 681 dup 3 index 0.5 mul add % xs xe ys ye dx dy r y x x3 682 2 index 5 index add % xs xe ys ye dx dy r y x x3 y3 683 lineto % xs xe ys ye dx dy r y x 684 dup 2 index 5 index 0.5 mul add % xs xe ys ye dx dy r y x x4 y4 685 lineto % xs xe ys ye dx dy r y x 686 dup 3 index 0.5 mul add 2 index % xs xe ys ye dx dy r y x x5 y5 687 lineto % xs xe ys ye dx dy r y x 688 dup 3 index 1.5 mul add 2 index % xs xe ys ye dx dy r y x x6 y6 689 lineto % xs xe ys ye dx dy r y x 690 dup 3 index 2.0 mul add % xs xe ys ye dx dy r y x x7 691 2 index 5 index 0.5 mul add % xs xe ys ye dx dy r y x x7 y7 692 lineto stroke % xs xe ys ye dx dy r y x 693 4 index add 694 } 695 loop pop 696 2 index add 697 } 698 loop pop pop pop pop pop pop pop pop 699} bind def 700$!end 701}; 702 703 704 705/** Pattern procedure. 706*/ 707static const char * const p19[] = { 708$!string-table 709/Octagons % xs xe ys ye dx co 710{ 711 3 index % xs xe ys ye dx co y 712 { 713 dup 4 index gt {exit} if 714 6 index % xs xe ys ye dx co y x 715 { 716 dup 7 index gt {exit} if % xs xe ys ye dx co y x 717 newpath 718 dup 3 index add % xs xe ys ye dx co y x x0 719 2 index % xs xe ys ye dx co y x x0 y0 720 moveto % xs xe ys ye dx co y x 721 dup 4 index add 3 index sub % xs xe ys ye dx co y x x1 722 2 index % xs xe ys ye dx co y x x1 y1 723 lineto % xs xe ys ye dx co y x 724 dup 4 index add % xs xe ys ye dx co y x x2 725 2 index 4 index add % xs xe ys ye dx co y x x2 y2 726 lineto % xs xe ys ye dx co y x 727 dup 4 index add % xs xe ys ye dx co y x x3 728 2 index 5 index add 4 index sub % xs xe ys ye dx co y x x3 y3 729 lineto % xs xe ys ye dx co y x 730 dup 4 index add 3 index sub % xs xe ys ye dx co y x x4 731 2 index 5 index add % xs xe ys ye dx co y x x4 y4 732 lineto % xs xe ys ye dx co y x 733 dup 3 index add % xs xe ys ye dx co y x x5 734 2 index 5 index add % xs xe ys ye dx co y x x5 y5 735 lineto % xs xe ys ye dx co y x 736 dup % xs xe ys ye dx co y x x6 737 2 index 5 index add 4 index sub % xs xe ys ye dx co y x x6 y6 738 lineto % xs xe ys ye dx co y x 739 dup % xs xe ys ye dx co y x x7 740 2 index 4 index add % xs xe ys ye dx co y x x7 y7 741 lineto closepath stroke % xs xe ys ye dx co y x 742 3 index add 743 } 744 loop pop 745 2 index add 746 } 747 loop pop pop pop pop pop pop pop 748} bind def 749$!end 750}; 751 752 753 754/** Pattern procedure. 755*/ 756static const char * const p20[] = { 757$!string-table 758/HorizontalTireTreads % xs xe ys ye dx 759{ 760 dup 0.5 mul % xs xe ys ye dx r 761 3 index % xs xe ys ye dx r y 762 { 763 dup 4 index gt {exit} if 764 6 index % xs xe ys ye dx r y x 765 { 766 dup 7 index gt {exit} if % xs xe ys ye dx r y x 767 dup 4 index add 2 index % xs xe ys ye dx r y x x2 y2 768 2 index 5 index add % xs xe ys ye dx r y x x2 y2 x1 769 4 index 6 index add % xs xe ys ye dx r y x x2 y2 x1 y1 770 4 index 6 index % xs xe ys ye dx r y x x2 y2 x1 y1 x0 y0 771 newpath moveto lineto lineto % xs xe ys ye dx r y x 772 stroke 773 3 index add 774 } 775 loop pop % xs xe ys ye dx r y 776 2 index add 777 } 778 loop % xs xe ys ye dx r y 779 pop pop pop pop pop pop pop 780} bind def 781$!end 782}; 783 784 785 786/** Pattern procedure. 787*/ 788static const char * const p21[] = { 789$!string-table 790/VerticalTireTreads % xs xe ys ye dx 791{ 792 dup 0.5 mul % xs xe ys ye dx r 793 5 index % xs xe ys ye dx r x 794 { 795 dup 6 index gt {exit} if 796 4 index % xs xe ys ye dx r x y 797 { 798 dup 5 index gt {exit} if 799 1 index 1 index 5 index add % xs xe ys ye dx r x y x2 y2 800 3 index 5 index add % xs xe ys ye dx r x y x2 y2 x1 801 3 index 6 index add % xs xe ys ye dx r x y x2 y2 x1 y1 802 5 index 5 index % xs xe ys ye dx r x y x2 y2 x1 y1 x0 y0 803 newpath moveto lineto lineto % xs xe ys ye dx r x y 804 stroke 805 3 index add 806 } 807 loop pop 808 2 index add 809 } 810 loop % xs xe ys ye dx r x 811 pop pop pop pop pop pop pop 812} bind def 813$!end 814}; 815 816 817 818/** Pattern names. 819*/ 820static const char * const pnames[] = { 821$!string-table 822ThirtyLeft 823ThirtyRight 824ThirtyHatch 825FourtyFiveLeft 826FourtyFiveRight 827FourtyFiveHatch 828HorizontalBricks 829VerticalBricks 830HorizontalLines 831VerticalLines 832CrossHatch 833HorizontalShinglesLeft 834HorizontalShinglesRight 835VerticalShinglesLeft 836VerticalShinglesRight 837FishScales 838SmallFishScales 839Circles 840Hexagons 841Octagons 842HorizontalTireTreads 843VerticalTireTreads 844$!end 845}; 846 847 848 849/** Pattern procedures. 850*/ 851static const char * const * pproc[] = { 852p00, p01, p02, p03, p04, p05, p06, p07, p08, p09, 853p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, 854p20, p21 855}; 856 857 858 859const char * const * 860dk4gra_eps_pattern_procedure(size_t i) 861{ 862 const char * const *back = NULL; 863#if DK4_USE_ASSERT 864 assert(DK4_GRA_PATTERN_MAX >= i); 865#endif 866 if (DK4_GRA_PATTERN_MAX >= i) { 867 back = pproc[i]; 868 } 869 return back; 870} 871 872 873 874const char * 875dk4gra_eps_pattern_name(size_t i) 876{ 877 const char *back = NULL; 878#if DK4_USE_ASSERT 879 assert(DK4_GRA_PATTERN_MAX >= i); 880#endif 881 if (DK4_GRA_PATTERN_MAX >= i) { 882 back = pnames[i]; 883 } 884 return back; 885} 886 887 888/* vim: set ai sw=4 ts=4 : */ 889