Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial commit of module textForSvg. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | textForSvg |
Files: | files | file ages | folders |
SHA3-256: |
377895fa777249d00cc446e2bd503083 |
User & Date: | kjnash 2025-07-09 21:26:53.634 |
Context
2025-07-09
| ||
21:26 | Initial commit of module textForSvg. Leaf check-in: 377895fa77 user: kjnash tags: textForSvg | |
16:47 | Create new branch named "textForSvg" check-in: c9fd94449e user: kjnash tags: textForSvg | |
Changes
Added examples/textForSvg/svg-demo.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 | #! /usr/bin/env wish # Example script for module textForSvg. # Copyright © Keith Nash 2021-2025 All Rights Reserved except as licensed below. # Tklib license. namespace eval :: { variable binary {} variable borderX 50.0 variable borderY 50.0 variable cnv .right.cnv variable configDict {binary {} directory {} family {} pixels {} monofam {} monopix {}} variable currentExample 1 variable directory {} variable examples variable fileName {} variable formattedExample 01 variable markedExample 1 variable openDir $::env(HOME) variable svgBinaryString {} variable toggledTxt {Shrink >>} variable totalExamples 220 variable txt .left.txt } proc createMainGui {} { destroy .top .bot .left .right frame .top panedwindow .bot -sashrelief groove -sashwidth 2p -sashpad 0p -bd 0 -showhandle 1 -handlesize 8p frame .left text .left.txt \ -bg white \ -width 60 \ -wrap word \ -undo 1 \ -highlightcolor #d9d9d9 \ -yscrollcommand {.left.scroll set} scrollbar .left.scroll \ -orient vertical \ -command {.left.txt yview} frame .right -bg white canvas .right.cnv -bg white -width 750 -height 820 -xscrollcommand {.right.horiz set} -yscrollcommand {.right.vert set} scrollbar .right.horiz -orient horizontal -command {.right.cnv xview} scrollbar .right.vert -orient vertical -command {.right.cnv yview} bind .left.txt <Shift-Return> {RunConverter; break} bind .left.txt <Control-Return> {RunConverter; break} bind .right.cnv <Configure> AdjustScroll return } proc createButtonBar {} { destroy .top.group1 .top.group2 .top.group3 .top.group4 .top.group5 labelframe .top.group1 -relief groove -bd 2 -labelanchor n -text {Example Code} labelframe .top.group5 -relief flat -bd 2 -labelanchor n -text { } labelframe .top.group2 -relief groove -bd 2 -labelanchor n -text {Source Files} labelframe .top.group3 -relief flat -bd 2 -labelanchor n -text { } labelframe .top.group4 -relief flat -bd 2 -labelanchor n -text { } button .top.group1.b0 -padx 1m -command prevExample -text < label .top.group1.b1 -textvariable formattedExample -width 3 button .top.group1.b2 -padx 1m -command nextExample -text > label .top.group1.b3 -bg #d0cfce -text { } button .top.group1.b4 -padx 0 -command mapExamplesScreen -text {See List} -width 8 button .top.group2.b4 -padx 2m -command fileOpen -text Open... button .top.group2.b5 -padx 2m -command fileSave -text Save button .top.group2.b6 -padx 2m -command fileSaveAs -text {Save As...} button .top.group3.b0 -padx 2m -command RunConverter -text Run button .top.group3.b3 -padx 2m -command imageSaveAs -text {Save Image As...} button .top.group3.b2 -padx 2m -command showConfigScreen -text {Configure, Help} button .top.group3.b4 -padx 2m -command showAboutScreen -text {About} button .top.group4.b1 -padx 2m -command toggleCanvasSize -textvariable toggledTxt -width 11 -anchor e button .top.group5.b0 -padx 2m -command ClearText -text Clear return } proc mapGui {} { pack .top -expand 0 -fill x pack .bot -expand 1 -fill both .bot add .left -sticky nsew -stretch always .bot add .right -sticky nsew -stretch always pack .left.scroll -side left -anchor nw -expand 0 -fill y pack .left.txt -side left -anchor nw -expand 1 -fill both grid .right.cnv .right.vert -sticky nsew grid .right.horiz -sticky nsew grid columnconfigure .right 0 -weight 1 grid rowconfigure .right 0 -weight 1 pack .top.group1 -side left -anchor nw -expand 0 -fill none -padx {3 0} -pady {0 2p} pack .top.group5 -side left -anchor nw -expand 0 -fill none -padx 5p -pady {0 2p} pack .top.group2 -side left -anchor nw -expand 0 -fill none -padx 0 -pady {0 2p} pack .top.group3 -side left -anchor nw -expand 0 -fill none -padx 5p -pady {0 2p} pack .top.group4 -side right -anchor ne -expand 0 -fill none -padx 0 -pady {0 2p} pack .top.group1.b0 -side left -padx 2p -pady 2p -anchor nw -fill y pack .top.group1.b1 -side left -padx 0 -pady 2p -anchor nw -fill y pack .top.group1.b2 -side left -padx 2p -pady 2p -anchor nw -fill y pack .top.group1.b3 -side left -padx 7p -pady 2p -anchor nw -fill y pack .top.group1.b4 -side left -padx 2p -pady 2p -anchor nw -fill y pack .top.group2.b4 -side left -padx 2p -pady 2p -anchor nw pack .top.group2.b5 -side left -padx 2p -pady 2p -anchor nw pack .top.group2.b6 -side left -padx 2p -pady 2p -anchor nw pack .top.group3.b0 -side left -padx 2p -pady 2p -anchor nw pack .top.group3.b3 -side left -padx 2p -pady 2p -anchor nw pack .top.group3.b2 -side left -padx 2p -pady 2p -anchor nw pack .top.group3.b4 -side left -padx 2p -pady 2p -anchor nw pack .top.group4.b1 -side left -padx 0 -pady 2p -anchor nw pack .top.group5.b0 -side left -padx 0 -pady 2p -anchor nw return } # Command maps everything except the # highest-level window .left.hfr proc createConfigScreen {} { destroy .left.hfr option add *TCombobox*Listbox.background #ffffff set msg1 [MakeMessage { |• If the pikchr binary is in the PATH, its directory can be left blank. }] set msg2 [MakeMessage { |• The default family for the standard font is Arial or a substitute. |• The default height for the standard font is 16 pixels. The value | may need adjustment for font families other than Arial. }] set msg3 [MakeMessage { |• The default family for the monospace font is Andale Mono or a substitute. |• The default height for the monospace font is 13 pixels. The value may | need adjustment for font families other than Andale Mono. }] frame .left.hfr frame .left.hfr.fr2 # PIKCHR labelframe .left.hfr.fr2.f3 \ -relief groove \ -bd 2 \ -labelanchor n \ -text {Location Of Pikchr Binary} \ -font TkHeadingFont label .left.hfr.fr2.f3.help1 -text $msg1 -justify left -anchor w label .left.hfr.fr2.f3.lab0 -font TkHeadingFont -text {Binary:} entry .left.hfr.fr2.f3.ent0 -width 16 -bg white label .left.hfr.fr2.f3.lab1 -font TkHeadingFont -text {Directory:} entry .left.hfr.fr2.f3.ent1 -width 30 -bg white # STD FONT labelframe .left.hfr.fr2.f4 \ -relief groove \ -bd 2 \ -labelanchor n \ -font TkHeadingFont \ -text {Standard Font} label .left.hfr.fr2.f4.help2 -text $msg2 -justify left -anchor w label .left.hfr.fr2.f4.lab2 -font TkHeadingFont -text {Standard Font Family:} ttk::combobox .left.hfr.fr2.f4.com2 -values [FontFamilies] label .left.hfr.fr2.f4.lab3 -font TkHeadingFont -text {Standard Font Height (pixels):} entry .left.hfr.fr2.f4.ent3 -width 6 -bg white # MONO FONT labelframe .left.hfr.fr2.f5 \ -relief groove \ -bd 2 \ -labelanchor n \ -font TkHeadingFont \ -text {Monospace Font} label .left.hfr.fr2.f5.help3 -text $msg3 -justify left -anchor w label .left.hfr.fr2.f5.lab4 -font TkHeadingFont -text {Monospace Font Family:} ttk::combobox .left.hfr.fr2.f5.com3 -values [FontFamilies mono] label .left.hfr.fr2.f5.lab5 -font TkHeadingFont -text {Monospace Font Height (pixels):} entry .left.hfr.fr2.f5.ent4 -width 6 -bg white # BUTTONS frame .left.hfr.fr2.f6 frame .left.hfr.fr2.f6.fr labelframe .left.hfr.fr2.f6.fr.bbar1 \ -relief groove \ -bd 2 \ -labelanchor n \ -text {Restore Defaults} button .left.hfr.fr2.f6.fr.bbar1.b2 \ -activebackground #dcddff \ -background #d0cfff \ -width 5 \ -text Sans \ -command {pickFont Sans} button .left.hfr.fr2.f6.fr.bbar1.b3 \ -activebackground #dcddff \ -background #d0cfff \ -width 5 \ -text Serif \ -command {pickFont Serif} button .left.hfr.fr2.f6.fr.bbar1.b4 \ -activebackground #dcddff \ -background #d0cfff \ -width 5 \ -text Mono \ -command {pickFont Mono} labelframe .left.hfr.fr2.f6.fr.bbar2 \ -relief groove \ -bd 2 \ -labelanchor n \ -text Actions button .left.hfr.fr2.f6.fr.bbar2.b0 \ -activebackground #dcddff \ -background #d0cfff \ -width 6 \ -text Cancel \ -command cancelConfigScreen button .left.hfr.fr2.f6.fr.bbar2.b1 \ -activebackground #dcddff \ -background #d0cfff \ -width 6 \ -text Save \ -command saveAndApplyConfigScreen # GEOM place .left.hfr.fr2 -anchor nw -x 5p -y 5p pack .left.hfr.fr2.f3 -anchor nw -fill x pack .left.hfr.fr2.f4 -anchor nw -fill x -pady {5p 0} pack .left.hfr.fr2.f5 -anchor nw -fill x -pady {5p 0} pack .left.hfr.fr2.f6 -anchor nw -fill x -pady {5p 0} grid .left.hfr.fr2.f3.help1 -columnspan 2 -sticky nsw -padx 5p -pady 3p grid .left.hfr.fr2.f3.lab0 .left.hfr.fr2.f3.ent0 -sticky nse -padx {15p 3p} grid .left.hfr.fr2.f3.lab1 .left.hfr.fr2.f3.ent1 -sticky nse -padx {15p 3p} -pady {0 3p} grid .left.hfr.fr2.f4.help2 -columnspan 2 -sticky nsw -padx 5p -pady 3p grid .left.hfr.fr2.f4.lab2 .left.hfr.fr2.f4.com2 -sticky nse -padx {15p 3p} grid .left.hfr.fr2.f4.lab3 .left.hfr.fr2.f4.ent3 -sticky nse -padx {15p 3p} -pady {0 3p} grid .left.hfr.fr2.f5.help3 -columnspan 2 -sticky nsw -padx 5p -pady 3p grid .left.hfr.fr2.f5.lab4 .left.hfr.fr2.f5.com3 -sticky nse -padx {15p 3p} grid .left.hfr.fr2.f5.lab5 .left.hfr.fr2.f5.ent4 -sticky nse -padx {15p 3p} -pady {0 3p} grid configure .left.hfr.fr2.f3.ent0 -sticky nsw -padx {0 13p} grid configure .left.hfr.fr2.f3.ent1 -sticky nsew -padx {0 3p} grid configure .left.hfr.fr2.f4.com2 -sticky nsw -padx {0 13p} grid configure .left.hfr.fr2.f4.ent3 -sticky nsw -padx {0 13p} grid configure .left.hfr.fr2.f5.com3 -sticky nsw -padx {0 13p} grid configure .left.hfr.fr2.f5.ent4 -sticky nsw -padx {0 13p} grid columnconfigure .left.hfr.fr2.f3 0 -weight 0 grid columnconfigure .left.hfr.fr2.f3 1 -weight 1 grid columnconfigure .left.hfr.fr2.f4 0 -weight 0 grid columnconfigure .left.hfr.fr2.f4 1 -weight 1 grid columnconfigure .left.hfr.fr2.f5 0 -weight 0 grid columnconfigure .left.hfr.fr2.f5 1 -weight 1 pack .left.hfr.fr2.f6.fr -padx 5p -pady 3p -side top -anchor n pack .left.hfr.fr2.f6.fr.bbar1 -side left -padx 18p pack .left.hfr.fr2.f6.fr.bbar2 -side left -padx 18p pack .left.hfr.fr2.f6.fr.bbar1.b2 -side left -padx 3p -pady 3p pack .left.hfr.fr2.f6.fr.bbar1.b3 -side left -padx 3p -pady 3p pack .left.hfr.fr2.f6.fr.bbar1.b4 -side left -padx 3p -pady 3p pack .left.hfr.fr2.f6.fr.bbar2.b0 -side left -padx 3p -pady 3p pack .left.hfr.fr2.f6.fr.bbar2.b1 -side left -padx 3p -pady 3p return } proc showConfigScreen {} { ValuesToConfigScreen place .left.hfr -x 0 -y 0 -anchor nw -relheight 1.0 -relwidth 1.0 SetButtonsState disabled .top.group3.b2 configure \ -text Cancel \ -state normal \ -command cancelConfigScreen \ -background #d0cfff \ -activebackground #dcddff .top.group4.b1 configure \ -background #d0cfff \ -activebackground #dcddff return } proc cancelConfigScreen {} { place forget .left.hfr .top.group3.b2 configure \ -text {Configure, Help} \ -command showConfigScreen \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] .top.group4.b1 configure \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] SetButtonsState normal return } proc ValuesToConfigScreen {} { variable configDict .left.hfr.fr2.f3.ent0 delete 0 end .left.hfr.fr2.f3.ent0 insert 0 [dict get $configDict binary] .left.hfr.fr2.f3.ent1 delete 0 end .left.hfr.fr2.f3.ent1 insert 0 [dict get $configDict directory] .left.hfr.fr2.f4.com2 set [dict get [font actual [list [dict get $configDict family] 10]] -family] .left.hfr.fr2.f4.ent3 delete 0 end .left.hfr.fr2.f4.ent3 insert 0 [dict get $configDict pixels] .left.hfr.fr2.f5.com3 set [dict get [font actual [list [dict get $configDict monofam] 10]] -family] .left.hfr.fr2.f5.ent4 delete 0 end .left.hfr.fr2.f5.ent4 insert 0 [dict get $configDict monopix] return } proc saveAndApplyConfigScreen {} { variable configDict set data {} dict set data binary [.left.hfr.fr2.f3.ent0 get] dict set data directory [.left.hfr.fr2.f3.ent1 get] dict set data family [.left.hfr.fr2.f4.com2 get] dict set data pixels [.left.hfr.fr2.f4.ent3 get] dict set data monofam [.left.hfr.fr2.f5.com3 get] dict set data monopix [.left.hfr.fr2.f5.ent4 get] set map [list \\\\ / \\ /] dict set data directory [string map $map [dict get $data directory]] if {[ValidateConfigValues $data]} { ReportError {one or more values are invalid} return } set configDict $data SaveConfigToFile ApplyConfigValues cancelConfigScreen RunConverter return } proc pickFont {style} { set fam [textForSvg::getDefaultFontFamily $style] if {$style eq {Mono}} { set pix 13 .left.hfr.fr2.f5.com3 set $fam .left.hfr.fr2.f5.ent4 delete 0 end .left.hfr.fr2.f5.ent4 insert end $pix } else { set pix 16 .left.hfr.fr2.f4.com2 set $fam .left.hfr.fr2.f4.ent3 delete 0 end .left.hfr.fr2.f4.ent3 insert end $pix } return } proc SaveConfigToFile {} { variable configDict if {$::tcl_platform(platform) eq {windows}} { set bak .bak set DOT {} } else { set bak ~ set DOT . } set configName [file join $::env(HOME) ${DOT}svg-text-demo-settings.cfg] if {[file exists ${configName}]} { if {[file exists ${configName}${bak}]} { file delete -force -- ${configName}${bak} } file rename -force -- ${configName} ${configName}${bak} } set fout [open ${configName} w] puts $fout $configDict close $fout return } proc ApplyConfigValues {} { variable configDict variable binary variable directory set binary [dict get $configDict binary] set directory [dict get $configDict directory] set tryFont [dict get $configDict family] textForSvg::configure -defaultheight [dict get $configDict pixels] if {[textForSvg::fontIsPresent $tryFont]} { textForSvg::configure -defaultfont $tryFont } set tryFont [dict get $configDict monofam] textForSvg::configure -monoheight [dict get $configDict monopix] if {[textForSvg::fontIsPresent $tryFont]} { textForSvg::configure -monofont $tryFont } return } # From WHD. proc MakeMessage {in} { regsub -all -line {^\s*\|} [string trim $in] {} } proc FontFamilies {{style any}} { if {$style ni {any mono}} { return -code error "argument \"style\" must be \"any\" or \"mono\"" } set ls {} set ff [lsort -unique [font families]] foreach fnt $ff { if {[string match {Noto Sans *} $fnt] || [string match {Noto Serif *} $fnt]} { # Skip the localized subfonts. } else { lappend ls $fnt } } if {$style eq {mono}} { set ff $ls set ls {} foreach fnt $ff { if {[font metrics [list $fnt 10] -fixed]} { lappend ls $fnt } } } return $ls } # Command maps everything except the # highest-level window .left.afr proc createAboutScreen {} { destroy .left.afr set msg3 [MakeMessage { |• Tk (8.7, 9.x) and tksvg (for Tk 8.6) can draw SVG images, | but without text labels. |• Module textForSvg implements a subset of SVG text labels. |• The goal is to allow Tk 8.6+ to fully display SVG images | generated by the pikchr command. The module is tested | by comparison with SVG rendering in the Google Chrome® | web browser. |• The pikchr example code is taken without modification or | omission from the pikchr site at https://pikchr.org/ and | is released under the pikchr license (0-clause BSD). |• N.B. Some examples have deliberate errors. This is | mentioned in a comment added to the example source code. | |• Module textForSvg is © 2021-2025 Keith Nash and is | released under the Tklib license. }] frame .left.afr frame .left.afr.fr2 labelframe .left.afr.fr2.f3 \ -relief groove \ -bd 2 \ -labelanchor n \ -text {About textForSvg} \ -font TkHeadingFont label .left.afr.fr2.f3.lab1 -text $msg3 -justify left -anchor w button .left.afr.fr2.f3.b0 \ -text Cancel \ -command cancelAboutScreen \ -activebackground #dcddff \ -background #d0cfff place .left.afr.fr2 -anchor nw -x 5p -y 5p pack .left.afr.fr2.f3 -anchor n pack .left.afr.fr2.f3.lab1 -anchor n -pady 5p -padx 3p pack .left.afr.fr2.f3.b0 -anchor n -pady 5p -padx 3p return } proc showAboutScreen {} { place .left.afr -x 0 -y 0 -anchor nw -relheight 1.0 -relwidth 1.0 SetButtonsState disabled .top.group3.b4 configure \ -text Cancel \ -state normal \ -command cancelAboutScreen \ -background #d0cfff \ -activebackground #dcddff .top.group4.b1 configure \ -background #d0cfff \ -activebackground #dcddff return } proc cancelAboutScreen {} { place forget .left.afr .top.group3.b4 configure \ -text {About} \ -command showAboutScreen \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] .top.group4.b1 configure \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] SetButtonsState normal return } proc getInitConfigValues {} { GetDefaultConfigValues set res [GetFileConfigValues] ApplyConfigValues if {$res} { ReportError {configuration file could not be loaded or had bad contents} # Continue with default values. return } return } proc GetDefaultConfigValues {} { variable configDict set bin pikchr if {$::tcl_platform(platform) eq {windows}} { append bin .exe } dict set configDict binary $bin dict set configDict directory {} dict set configDict family [textForSvg::getDefaultFontFamily Sans] dict set configDict pixels 16 dict set configDict monofam [textForSvg::getDefaultFontFamily Mono] dict set configDict monopix 13 return } # Read config file values into configDict. # Return 1 if there is a problem with the file or the values; 0 for no problem or no file. proc GetFileConfigValues {} { variable configDict # If valid data available from stored configuration file, use it. # Otherwise, keep existing values. if {$::tcl_platform(platform) eq {windows}} { set DOT {} } else { set DOT . } set configName [file join $::env(HOME) ${DOT}svg-text-demo-settings.cfg] if {![file exists $configName]} { return 0 } if {![file readable $configName]} { return 1 } if {[catch { set fin [open ${configName}] set data [read $fin] close $fin }]} { return 1 } if {[ValidateConfigValues $data]} { return 1 } dict set configDict binary [dict get $data binary] dict set configDict directory [dict get $data directory] dict set configDict family [dict get $data family] dict set configDict pixels [dict get $data pixels] dict set configDict monofam [dict get $data monofam] dict set configDict monopix [dict get $data monopix] return 0 } # ------------------------------------------------------------------------------ # Proc ValidateConfigValues # ------------------------------------------------------------------------------ # Test the configuration data in argument "data". # Return 0 if data accepted, 1 if rejected. # Reject data that has square brackets, dollar sign, or backslash. # Reject data if it is not a valid list. # Reject data if it is not a dict with keys binary, directory, family, and pixels. # Reject data if "binary" value is empty. # Reject data if "family" value is not in [font families]. # Reject data if "pixels" value is not a number >= 1.0. # ------------------------------------------------------------------------------ proc ValidateConfigValues {data} { set cleanData [string map [list \[ {} \] {} \$ {} \\ /] $data] if {$cleanData ne $data} { return 1 } if {![string is list -strict $data]} { return 1 } foreach key {binary directory family pixels} { if {![dict exists $data $key]} { return 1 } } set bin [dict get $data binary] set fam [dict get $data family] set pix [dict get $data pixels] set mfam [dict get $data monofam] set mpix [dict get $data monopix] if {$bin eq {}} { return 1 } if {$fam ni [font families]} { return 1 } if {![string is double -strict $pix] || ($pix < 1.0)} { return 1 } if {$mfam ni [font families]} { return 1 } if {![string is double -strict $mpix] || ($mpix < 1.0)} { return 1 } return 0 } # Command maps everything except the # highest-level window .left.fr proc createExamplesScreen {} { variable totalExamples set Nwide 15 set Nhigh 15 if {($Nwide * $Nhigh) < $totalExamples} { ReportError "Have $totalExamples examples; but \ buttons for [expr {$Nwide * $Nhigh}]." return } destroy .left.fr frame .left.fr frame .left.fr.fr2 -bd 2 -relief groove place .left.fr.fr2 -x 13p -y 13p -anchor nw set sta normal for {set i 0} {$i < $Nhigh} {incr i} { set row {} for {set j 0} {$j < $Nwide} {incr j} { set k [expr {$i * $Nwide + $j + 1}] if {$k > $totalExamples} { break } button .left.fr.fr2.b$k \ -text [format %03u $k] \ -command [list loadExample $k] \ -cursor arrow \ -state $sta \ -bd 1p -padx 1p -pady 1p lappend row .left.fr.fr2.b$k } grid {*}$row -padx 1p -pady 1p } return } proc mapExamplesScreen {} { place .left.fr -x 0 -y 0 -anchor nw -relheight 1.0 -relwidth 1.0 SetButtonsState disabled .top.group1.b4 configure \ -text Cancel \ -command unmapExamplesScreen \ -state normal \ -background #d0cfff \ -activebackground #dcddff .top.group4.b1 configure \ -background #d0cfff \ -activebackground #dcddff return } proc unmapExamplesScreen {} { place forget .left.fr .top.group1.b4 configure \ -text {See List} \ -command mapExamplesScreen \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] .top.group4.b1 configure \ -background [.top.group2.b4 cget -background] \ -activebackground [.top.group2.b4 cget -activebackground] SetButtonsState normal return } proc prevExample {} { variable currentExample variable formattedExample if {$currentExample == 1} { return } else { incr currentExample -1 set formattedExample [format %03u $currentExample] .top.group1.b2 configure -state normal } if {$currentExample == 1} { .top.group1.b0 configure -state disabled } loadExample $currentExample return } proc nextExample {} { variable currentExample variable formattedExample variable totalExamples if {$currentExample == $totalExamples} { return } else { incr currentExample set formattedExample [format %03u $currentExample] .top.group1.b0 configure -state normal } if {$currentExample == $totalExamples} { .top.group1.b2 configure -state disabled } loadExample $currentExample return } proc SetButtonsState {bst} { variable currentExample variable totalExamples foreach wbut { .top.group1.b0 .top.group1.b1 .top.group1.b2 .top.group1.b4 .top.group5.b0 .top.group2.b4 .top.group2.b5 .top.group2.b6 .top.group3.b0 .top.group3.b2 .top.group3.b3 .top.group3.b4 } { $wbut configure -state $bst } if {$currentExample == 1} { .top.group1.b0 configure -state disabled } if {$currentExample == $totalExamples} { .top.group1.b2 configure -state disabled } return } proc markSelectedExample {} { variable currentExample variable markedExample UnmarkExample $markedExample MarkExample $currentExample set markedExample $currentExample return } proc MarkExample {i} { .left.fr.fr2.b$i configure -bd 2p -relief sunken grid configure .left.fr.fr2.b$i -padx 0p -pady 0p return } proc UnmarkExample {i} { .left.fr.fr2.b$i configure -bd 1p -relief raised grid configure .left.fr.fr2.b$i -padx 1p -pady 1p return } proc toggleCanvasSize {} { variable toggledTxt if {$toggledTxt eq {Unshrink <<}} { UnshrinkCanvas } else { ShrinkCanvas } return } proc UnshrinkCanvas {} { variable toggledTxt variable cnv if {$toggledTxt eq {Unshrink <<}} { set toggledTxt {Shrink >>} # $cnv configure -width 750 .bot paneconfigure .right -hide 0 } return } proc ShrinkCanvas {} { variable toggledTxt variable cnv if {$toggledTxt eq {Shrink >>}} { set toggledTxt {Unshrink <<} # $cnv configure -width 5 .bot paneconfigure .right -hide 1 } return } proc fileOpen {} { variable txt variable fileName variable openDir set fileTypes {{{PIKCHR Source} .pikchr} {{All Files} *}} set opts {} lappend opts -filetypes $fileTypes -parent . -title "Open Pikchr Source File" if {$::tcl_platform(platform) eq {windows}} { lappend opts -defaultextension .pikchr } if {$openDir ne {}} { lappend opts -initialdir $openDir } set file [tk_getOpenFile {*}$opts] if {$file eq {}} { return } set fileName $file set openDir [file dirname $file] set fin [open $file] set data [read $fin] close $fin ClearText set fileName $file $txt insert end $data RunConverter return } # Return Value: 1 for success, 0 for failure. proc fileSave {{again 0}} { variable fileName variable txt if {($fileName eq {}) && !$again} { return [fileSaveAs] } elseif {$fileName eq {}} { return 0 } set data [$txt get 1.0 end-1c] set fout [open $fileName w] puts -nonewline $fout $data close $fout return 1 } # Return Value: 1 for success, 0 for failure. proc fileSaveAs {} { variable fileName variable openDir set fileTypes {{{PIKCHR Source} .pikchr} {{All Files} *}} set opts {} lappend opts -filetypes $fileTypes -parent . -title "Save Pikchr Source File As" if {$::tcl_platform(platform) eq {windows}} { lappend opts -defaultextension .pikchr } if {$fileName eq {}} { lappend opts -initialdir $openDir } else { set fn [file normalize $fileName] set fd [file dirname $fn] set ft [file tail $fn] lappend opts -initialdir $fd -initialfile $ft } set file [tk_getSaveFile {*}$opts] if {$file eq {}} { return 0 } set openDir [file dirname $file] set fileName $file fileSave 1 } proc loadExample {i} { variable currentExample variable formattedExample variable examples variable txt variable fileName set fileName {} set currentExample $i set formattedExample [format %03u $currentExample] set data [string trim $examples($i) \n]\n clearDisplay $txt insert end $data unmapExamplesScreen markSelectedExample RunConverter return } proc clearDisplay {} { ClearText ClearImage return } proc ClearText {} { variable txt $txt delete 1.0 end-1c return } proc ClearImage {} { variable cnv variable svgBinaryString set svgBinaryString {} $cnv delete {*}[$cnv find all] catch {image delete img1} return } proc imageSaveAs {{extn .png}} { variable fileName variable openDir if {$extn ni {.png .svg}} { set extn * } if {$fileName ne {}} { set fileInitials [list \ -initialfile [file rootname [file tail $fileName]] \ -initialdir [file dirname $fileName] \ ] } else { set fileInitials [list -initialdir $openDir] } if {$::tcl_platform(platform) eq {windows}} { set defaultExt [list -defaultextension $extn] } else { set defaultExt {} } set fileTypes { \ {{PNG Images} .png} \ {{SVG Images} .svg} \ {{All Files} *} \ } set newFilePath [tk_getSaveFile \ -filetypes $fileTypes \ -title "Save Image As" \ -parent . \ {*}$fileInitials \ {*}$defaultExt] if {$newFilePath eq ""} { # User has cancelled. return } # We've got a new filename $newFilePath from the requester. set openDir [file dirname $newFilePath] imageSave $newFilePath return } proc imageSave {file} { variable cnv variable svgBinaryString if {[file extension $file] eq {.svg}} { set data $svgBinaryString set opts {-translation binary} } else { set data [textForSvg::imageCreatePhoto -- -data $svgBinaryString] set opts {-translation binary} } set fout [open $file w] fconfigure $fout {*}$opts puts -nonewline $fout $data close $fout return } # ------------------------------------------------------------------------------ # Proc RunConverter # ------------------------------------------------------------------------------ # The command executed by the "Run" button. Reads Pikchr source from the left # window, and draws the SVG image in the right window as a canvas with image and # text items. # # Arguments: none # Return Value: none # ------------------------------------------------------------------------------ proc RunConverter {} { variable txt variable cnv variable borderX variable borderY set txtIn [$txt get 1.0 end-1c] set xmlData [Pik2Svg $txtIn] UnshrinkCanvas SvgToImage $xmlData $borderX $borderY AdjustScroll $cnv xview moveto 0 $cnv yview moveto 0 return } proc AdjustScroll {} { variable cnv variable borderX variable borderY set imgName img1 if {"img1" in [image names]} { set imgW [image width $imgName] set imgH [image height $imgName] } else { set imgW 0 set imgH 0 } set maxW [expr {max($imgW + 2 * $borderX, [winfo width $cnv])}] set maxH [expr {max($imgH + 2 * $borderY, [winfo height $cnv])}] $cnv configure -scrollregion [list 0 0 $maxW $maxH] return } # ------------------------------------------------------------------------------ # Proc Pik2Svg # ------------------------------------------------------------------------------ # Convert pikchr source to SVG image data. # # Arguments: # pik - data in pikchr format, Tcl string # # Return Value: data in SVG format, Tcl string # ------------------------------------------------------------------------------ proc Pik2Svg {pik} { variable binary variable directory if {$directory eq {}} { # binary is in the PATH set path $binary } else { set path [file join [file normalize $directory] $binary] } if {$::tcl_platform(platform) eq "windows"} { set bin pikchr.exe } else { set bin pikchr } if {![file exists $path]} { ReportError "Requested file \"$path\" does not exist.\nClick the\ \"Configure, Help\" button\nto specify the $bin file." return } if {![file executable $path]} { ReportError "Requested file \"$path\" is not executable." return } if {[catch {exec $path --svg-only - << $pik} svg]} { ReportError $svg return } string range $svg [string first {<svg } $svg] end } # ------------------------------------------------------------------------------ # Proc SvgToImage # ------------------------------------------------------------------------------ # Use SVG data to create a canvas with SVG image item and text items for labels. # # Arguments: # xmlData - SVG image data as a Tcl string # xoff - horizontal offset # yoff - vertical offset # # Return Value: none # ------------------------------------------------------------------------------ proc SvgToImage {xmlData {xoff 0.0} {yoff 0.0}} { variable cnv variable svgBinaryString ClearImage set xmlDataBinary [string trim [textForSvg::strictConvertTo $xmlData utf-8]] if {$xmlDataBinary ni {{} {<!-- empty pikchr diagram -->}}} { set svgBinaryString $xmlDataBinary image create photo img1 -data $xmlDataBinary set item [$cnv create image $xoff $yoff -image img1 -anchor nw] textForSvg::addText $xmlData $cnv $xoff $yoff 0 } return } proc loadPackages {} { set err 0 set missing {} foreach {pkg ver} { Tcl 8.6- Tk 8.6- htmlparse {} Img {} tdom 0.9 tksvg 0.14 textForSvg 1.0- base64 {} } { if {($::tk_version > 8.6) && ($pkg eq {tksvg})} { continue } if {$ver eq {}} { set blurb $pkg } else { set blurb "$pkg version $ver" } if {[catch {package require $pkg {*}$ver} res]} { append msg "$res\n" lappend missing $pkg set err 1 } else { append msg "package $pkg version $res was successfully loaded\n" } } if {$err} { append msg "\nErrors with package(s) [join $missing {, }] - cannot continue." set msg [string trim $msg] after idle "[list .dlg.msg configure -font TkDefaultFont -wraplength 5i] [list wm transient .dlg {}] wm withdraw ." tk_dialog .dlg Packages $msg {} 0 OK destroy .dlg wm deiconify . } return $err } proc ReportError {msg} { after idle [list .dlg.msg configure -font TkDefaultFont -wraplength 5i -justify center] after idle [list wm transient .dlg .] after idle [list bind .dlg <Unmap> NoHide] tk_dialog .dlg Error $msg {} 0 OK destroy .dlg return } proc NoHide {} { set w .dlg if { ([winfo ismapped .]) && ([winfo exists $w]) && (![winfo ismapped $w]) } { wm deiconify $w focus -force [focus -lastfor $w] } return } proc mainScript {} { variable currentExample if {[loadPackages]} { exit } getInitConfigValues definePikchrExamples createMainGui createButtonBar mapGui createExamplesScreen createConfigScreen createAboutScreen clearDisplay markSelectedExample loadExample $currentExample update idletasks wm geometry . [wm geometry .] return } proc definePikchrExamples {} { variable examples variable totalExamples # In the text below, examples have \ at EOL doubled # so the characters are not consumed by Tcl. array unset examples #indent-4 set examples(1) { # pikchr.org file doc/homepage.md extract 01 arrow right 200% "Markdown" "Source" box rad 10px "Markdown" "Formatter" "(markdown.c)" fit arrow right 200% "HTML+SVG" "Output" arrow <-> down 70% from last box.s box same "Pikchr" "Formatter" "(pikchr.c)" fit } set examples(2) { # pikchr.org file doc/boxobj.md extract 01 A: box thick line thin color gray left 70% from 2mm left of A.nw line same from 2mm left of A.sw text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below A.sw X2: line thin color gray down 50% from 2mm below A.se text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> } set examples(3) { # pikchr.org file doc/boxobj.md extract 02 A: box thick rad 0.3*boxht line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.s) X4: line thin color gray right 70% from A.rad above start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X3) down 30% <- line thin color gray from (previous text,X4) up 30% <- } set examples(4) { # pikchr.org file doc/boxobj.md extract 03 A: box thin dot ".c" above at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw A: box thin at 2.0*boxwid right of previous box rad 15px dot ".c" above at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(5) { # pikchr.org file doc/chop.md extract 01 file "A" cylinder "B" at 5cm heading 125 from A arrow <-> from A to B "from A to B" aligned above color red arrow <-> from A to B chop "from A to B chop" aligned below color blue } set examples(6) { # pikchr.org file doc/circleobj.md extract 01 A: circle thick rad 120% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.s) X4: line thin color gray right 70% from A.rad above start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X3) down 30% <- line thin color gray from (previous text,X4) up 30% <- line thin color gray <-> from A.sw to A.ne line thin color gray from A.ne go 0.5*A.rad ne then 0.25*A.rad east text " diameter" ljust at end of previous line } set examples(7) { # pikchr.org file doc/circleobj.md extract 02 A: circle thin dot ".c" above at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(8) { # pikchr.org file doc/compassangle.md extract 01 C: dot arrow up from C; text " 0°" arrow right from C; text " 90°" rjust arrow down from C; text "180°" below arrow left from C; text "270° " ljust } set examples(9) { # pikchr.org file doc/cylinderobj.md extract 01 A: cylinder thick rad 150% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.ne) X4: line thin color gray right 70% from A.rad below start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X4) down 30% <- line thin color gray from (previous text,X3) up 30% <- } set examples(10) { # pikchr.org file doc/cylinderobj.md extract 02 A: cylinder thin rad 80% dot ".c" below at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(11) { # pikchr.org file doc/diamondobj.md extract 01 D: diamond "Cardinal" "Points" dot ".n" above at D.n dot " .e" ljust at D.e dot ".s" below at D.s dot ".w " rjust at D.w } set examples(12) { # pikchr.org file doc/diamondobj.md extract 02 box width 150% invis "“Diamond”" "Label" line from last.w to last.n to last.e to last.s close } set examples(13) { # pikchr.org file doc/diamondobj.md extract 03 # Deliberate Error: text overflow. box invis "“Diamond”" "Label" line from last.w to last.n to last.e to last.s close } set examples(14) { # pikchr.org file doc/diamondobj.md extract 04 text "Unfitted:" diamond "D" text "Properly fitted:" diamond "D" fit text "Badly fitted:" box invis "D" fit line from last.w to last.n to last.e to last.s close } set examples(15) { # pikchr.org file doc/diamondobj.md extract 05 D: diamond "Ordinal" "Points" dot " .ne" ljust above at D.ne dot " .se" ljust below at D.se dot ".sw " rjust below at D.sw dot ".nw " rjust above at D.nw } set examples(16) { # pikchr.org file doc/diamondobj.md extract 06 D: diamond thick "Diamond" "Dimensions" width 125% height 125% X1: line thin color gray left 70% from 4mm left of (D.w,D.n) X2: line same from 4mm left of (D.w,D.s) text "height" small at 1/2 way between X1 and X2 line thin color gray from previous text.n up until even with X1 -> line thin color gray from previous text.s down until even with X2 -> X3: line thin color gray down 50% from 2mm below (D.w,D.s) X4: line same from 2mm below (D.e,D.s) text "width" small at 1/2 way between X3 and X4 line thin color gray from previous text.w left until even with X3 -> line thin color gray from previous text.e right until even with X4 -> diamondht *= 1.25 diamondwid *= 1.25 diamond thick "Diamond" "Dimensions" at 1.5in right of D } set examples(17) { # pikchr.org file doc/differences.md extract 01 oval "oval" move diamond "diamond" move cylinder "cylinder" move file "file" move dot " dot" ljust } set examples(18) { # pikchr.org file doc/differences.md extract 02 box rad 15px "box" "radius 15px" } set examples(19) [UnguardBs { # pikchr.org file doc/differences.md extract 03 arrow rad 10px go heading 30 then go 200% heading 175 \\ then go 150% west "arrow" below "radius 10px" below }] set examples(20) { # pikchr.org file doc/differences.md extract 04 boxrad = 12px box color blue "color blue" move box fill lightgray "fill lightgray" move box color white fill blue "color white" "fill blue" } set examples(21) { # pikchr.org file doc/differences.md extract 05 boxrad = 12px box thin "thin" move box "(default)" italic move box thick "thick" move box thick thick "thick" "thick" } set examples(22) [UnguardBs { # pikchr.org file doc/differences.md extract 06 box "bold" bold "italic" italic "big" big "small" small "monospace" mono fit line from 1cm right of previous.se to 3cm right of previous.ne \\ "aligned" above aligned }] set examples(23) { # pikchr.org file doc/differences.md extract 07 box "default" italic "box" italic move box "width 150%" width 150% move box "wid 75%" wid 75% } set examples(24) { # pikchr.org file doc/differences.md extract 08 file "A" cylinder "B" at 5cm heading 125 from A arrow <-> from A to B chop "from A to B chop" aligned above } set examples(25) { # pikchr.org file doc/differences.md extract 09 box thick thick fill lightgray "box" "thick" "fill lightgray" move file same as last box "file" "same as" "last box" rad filerad } set examples(26) { # pikchr.org file doc/ellipseobj.md extract 01 A: ellipse thick line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> } set examples(27) { # pikchr.org file doc/ellipseobj.md extract 02 A: ellipse thin dot ".c" below at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(28) [UnguardBs { # pikchr.org file doc/examples.md extract 01 box color red wid 2.6in \\ "Click on any diagram on this page" big \\ "to see the Pikchr source text" big }] set examples(29) [UnguardBs { # pikchr.org file doc/differences.md extract 15 scale = 0.8 linewid *= 0.5 circle "C0" fit circlerad = previous.radius arrow circle "C1" arrow circle "C2" arrow circle "C4" arrow circle "C6" circle "C3" at dist(C2,C4) heading 30 from C2 d1 = dist(C2,C3.ne)+2mm line thin color gray from d1 heading 30 from C2 \\ to d1+1cm heading 30 from C2 line thin color gray from d1 heading 0 from C2 \\ to d1+1cm heading 0 from C2 spline thin color gray <-> \\ from d1+8mm heading 0 from C2 \\ to d1+8mm heading 10 from C2 \\ to d1+8mm heading 20 from C2 \\ to d1+8mm heading 30 from C2 \\ "30°" aligned below small X1: line thin color gray from circlerad+1mm heading 300 from C3 \\ to circlerad+6mm heading 300 from C3 X2: line thin color gray from circlerad+1mm heading 300 from C2 \\ to circlerad+6mm heading 300 from C2 line thin color gray <-> from X2 to X1 "distance" aligned above small \\ "C2 to C4" aligned below small }] set examples(30) [UnguardBs { # pikchr.org file doc/teardown01.md extract 02 linewid *= 0.5 circle "C0" fit circlerad = previous.radius arrow circle "C1" arrow circle "C2" arrow circle "C4" arrow circle "C6" circle "C3" at dist(C2,C4) heading 30 from C2 d1 = dist(C2,C3.ne)+2mm line thin color gray from d1 heading 30 from C2 \\ to d1+1cm heading 30 from C2 line thin color gray from d1 heading 0 from C2 \\ to d1+1cm heading 0 from C2 spline thin color gray <-> \\ from d1+8mm heading 0 from C2 \\ to d1+8mm heading 10 from C2 \\ to d1+8mm heading 20 from C2 \\ to d1+8mm heading 30 from C2 \\ "30°" aligned below small X1: line thin color gray from circlerad+1mm heading 300 from C3 \\ to circlerad+6mm heading 300 from C3 X2: line thin color gray from circlerad+1mm heading 300 from C2 \\ to circlerad+6mm heading 300 from C2 line thin color gray <-> from X2 to X1 "distance" aligned above small \\ "C2 to C4" aligned below small }] set examples(31) [UnguardBs { # pikchr.org file tests/test54.pikchr margin = 4mm All: [ file thick thick fill lightgray \\ "wide-file" "test 1" "abcde" "uvwxyz" "bottom" fit move cylinder thick thick fill lightgray "cylinder" "test 1" fit move diamond thick thick fill lightgray "wide-diamond" "test 1" "abcde" "uvwxyz" \\ "bottom" fit ] text "Fit & Background for" "File, Cylinder, and Diamond" \\ with .s at .2 above All.n }] set examples(32) { # pikchr.org file fuzzcases/monospace.pikchr box "monospace" monospace fit } set examples(33) [UnguardBs { # pikchr.org file doc/examples.md extract 06 scale = 0.8 fill = white linewid *= 0.5 circle "C0" fit circlerad = previous.radius arrow circle "C1" arrow circle "C2" arrow circle "C4" arrow circle "C6" circle "C3" at dist(C2,C4) heading 30 from C2 arrow circle "C5" arrow from C2 to C3 chop C3P: circle "C3'" at dist(C4,C6) heading 30 from C6 arrow right from C3P.e C5P: circle "C5'" arrow from C6 to C3P chop box height C3.y-C2.y \\ width (C5P.e.x-C0.w.x)+linewid \\ with .w at 0.5*linewid west of C0.w \\ behind C0 \\ fill 0xc6e2ff thin color gray box same width previous.e.x - C2.w.x \\ with .se at previous.ne \\ fill 0x9accfc "trunk" below at 2nd last box.s "feature branch" above at last box.n circle "C0" at 3.7cm south of C0 arrow circle "C1" arrow circle "C2" arrow circle "C4" arrow circle "C6" circle "C3" at dist(C2,C4) heading 30 from C2 arrow circle "C5" arrow circle "C7" arrow from C2 to C3 chop arrow from C6 to C7 chop box height C3.y-C2.y \\ width (C7.e.x-C0.w.x)+1.5*C1.radius \\ with .w at 0.5*linewid west of C0.w \\ behind C0 \\ fill 0xc6e2ff thin color gray box same width previous.e.x - C2.w.x \\ with .se at previous.ne \\ fill 0x9accfc "trunk" below at 2nd last box.s "feature branch" above at last box.n }] set examples(34) { # pikchr.org file tests/test40.pikchr $one = 1.0 $one += 2.0 $two = $one $two *= 3.0 print $one, $two $three -= 11 $three /= 2 print $three box "should be..." italic "3 9" bold "-5.5" bold fit } set examples(35) [UnguardBs { # pikchr.org file doc/examples.md extract 10 circle "DISK" arrow "character" "defns" right 150% CPU: box "CPU" "(16-bit mini)" arrow <- from top of CPU up "input " rjust move right from CPU.e CRT: " CRT" ljust line from CRT - 0,0.075 up 0.15 \\ then right 0.5 \\ then right 0.5 up 0.25 \\ then down 0.5+0.15 \\ then left 0.5 up 0.25 \\ then left 0.5 arrow from CPU.e right until even with previous.start Paper: CRT + 1.05,0.75 arrow <- from Paper down 1.5 " ... paper" ljust at end of last arrow + 0, 0.25 circle rad 0.05 at Paper + (-0.055, -0.25) circle rad 0.05 at Paper + (0.055, -0.25) " rollers" ljust at Paper + (0.1, -0.25) }] set examples(36) { # pikchr.org file doc/fileobj.md extract 01 A: file thick rad 100% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.n) X4: line thin color gray right 70% from A.rad below start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X4) down 30% <- line thin color gray from (previous text,X3) up 30% <- } set examples(37) { # pikchr.org file doc/fileobj.md extract 02 A: file thin rad 80% dot ".c" below at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(38) { # pikchr.org file doc/fit.md extract 01 box "with" "\"fit\"" fit move box "without" "\"fit\"" } set examples(39) [UnguardBs { # pikchr.org file doc/examples.md extract 02 filewid *= 1.2 Src: file "pikchr.y"; move LemonSrc: file "lemon.c"; move Lempar: file "lempar.c"; move arrow down from LemonSrc.s CC1: oval "C-Compiler" ht 50% arrow " generates" ljust above Lemon: oval "lemon" ht 50% arrow from Src chop down until even with CC1 \\ then to Lemon.nw rad 20px "Pikchr source " rjust "code input " rjust \\ at 2nd vertex of previous arrow from Lempar chop down until even with CC1 \\ then to Lemon.ne rad 20px " parser template" ljust " resource file" ljust \\ at 2nd vertex of previous PikSrc: file "pikchr.c" with .n at lineht below Lemon.s arrow from Lemon to PikSrc chop arrow down from PikSrc.s CC2: oval "C-Compiler" ht 50% arrow Out: file "pikchr.o" "or" "pikchr.exe" wid 110% }] set examples(40) [UnguardBs { # pikchr.org file doc/build.md extract 01 filewid *= 1.2 Src: file "pikchr.y"; move LemonSrc: file "lemon.c"; move Lempar: file "lempar.c"; move arrow down from LemonSrc.s CC1: oval "C-Compiler" ht 50% arrow " generates" ljust above Lemon: oval "lemon" ht 50% arrow from Src chop down until even with CC1 \\ then to Lemon.nw rad 10px "Pikchr source " rjust "code input " rjust \\ at 2nd vertex of previous arrow from Lempar chop down until even with CC1 \\ then to Lemon.ne rad 10px " parser" ljust " template" ljust \\ at 2nd vertex of previous PikSrc: file "pikchr.c" with .n at lineht below Lemon.s arrow from Lemon to PikSrc chop arrow down from PikSrc.s CC2: oval "C-Compiler" ht 50% arrow Out: file "pikchr.o" "or" "pikchr.exe" wid 110% spline <- from 1mm west of Src.w go 60% heading 250 \\ then go 40% heading 45 then go 60% heading 250 \\ thin color gray box invis "Canonical" ljust small "Source code" ljust small fit \\ with .e at end of last spline width 90% spline <- from 1mm west of PikSrc.w go 60% heading 250 \\ then go 40% heading 45 then go 60% heading 250 \\ thin color gray box invis "Generated" ljust small \\ "C-code" ljust small fit \\ with .e at end of last spline width 90% }] set examples(41) [UnguardBs { # pikchr.org file examples/swimlane.pikchr # demo label: Swimlanes $laneh = 0.75 # Draw the lanes down box width 3.5in height $laneh fill 0xacc9e3 box same fill 0xc5d8ef box same as first box box same as 2nd box line from 1st box.sw+(0.2,0) up until even with 1st box.n \\ "Alan" above aligned line from 2nd box.sw+(0.2,0) up until even with 2nd box.n \\ "Betty" above aligned line from 3rd box.sw+(0.2,0) up until even with 3rd box.n \\ "Charlie" above aligned line from 4th box.sw+(0.2,0) up until even with 4th box.n \\ "Darlene" above aligned # fill in content for the Alice lane right A1: circle rad 0.1in at end of first line + (0.2,-0.2) \\ fill white thickness 1.5px "1" arrow right 50% circle same "2" arrow right until even with first box.e - (0.65,0.0) ellipse "future" fit fill white height 0.2 width 0.5 thickness 1.5px A3: circle same at A1+(0.8,-0.3) "3" fill 0xc0c0c0 arrow from A1 to last circle chop "fork!" below aligned # content for the Betty lane B1: circle same as A1 at A1-(0,$laneh) "1" arrow right 50% circle same "2" arrow right until even with first ellipse.w ellipse same "future" B3: circle same at A3-(0,$laneh) "3" arrow right 50% circle same as A3 "4" arrow from B1 to 2nd last circle chop # content for the Charlie lane C1: circle same as A1 at B1-(0,$laneh) "1" arrow 50% circle same "2" arrow right 0.8in "goes" "offline" C5: circle same as A3 "5" arrow right until even with first ellipse.w \\ "back online" above "pushes 5" below "pulls 3 & 4" below ellipse same "future" # content for the Darlene lane D1: circle same as A1 at C1-(0,$laneh) "1" arrow 50% circle same "2" arrow right until even with C5.w circle same "5" arrow 50% circle same as A3 "6" arrow right until even with first ellipse.w ellipse same "future" D3: circle same as B3 at B3-(0,2*$laneh) "3" arrow 50% circle same "4" arrow from D1 to D3 chop }] set examples(42) { # pikchr.org file doc/numprop.md extract 01 box "radius 0" move box "radius 5px" rad 5px move box "radius 20px" rad 20px } set examples(43) { # pikchr.org file doc/numprop.md extract 02 C: cylinder line thin left from C.nw - (2mm,0) line thin left from C.nw - (2mm,C.radius) arrow <- from 3/4<first line.start,first line.end> up 30% arrow <- from 3/4<2nd line.start,2nd line.end> down 30% text "radius" above at end of 1st arrow } set examples(44) { # pikchr.org file doc/numprop.md extract 03 cylinder "radius 50%" rad 50% move cylinder "radius 100%" rad 100% move cylinder "radius 200%" "height 200%" rad 200% ht 200% } set examples(45) { # pikchr.org file doc/numprop.md extract 04 F: file line thin from 2mm right of (F.e,F.n) right 75% line thin from F.rad below start of previous right 75% arrow <- from 3/4<first line.start,first line.end> up 30% arrow <- from 3/4<2nd line.start,2nd line.end> down 30% text "radius" above at end of 1st arrow } set examples(46) [UnguardBs { # pikchr.org file doc/numprop.md extract 05 line go 2cm heading 40 then 4cm heading 165 then 1cm heading 280\\ "radius" "0" move to 3cm right of previous.start line same "radius" "15px" rad 15px move to 3cm right of previous.start line same "radius" "30px" rad 30px }] set examples(47) { # pikchr.org file doc/ovalobj.md extract 01 A: oval thick X0: line thin color gray left 70% from 2mm left of (A.w,A.n) X1: line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<X0,X1>) line thin color gray from previous text.n up until even with X0 -> line thin color gray from previous text.s down until even with X1 -> X2: line thin color gray down 50% from 2mm below (A.w,A.s) X3: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X2,X3>,6/8<X2.start,X2.end>) line thin color gray from previous text.w left until even with X2 -> line thin color gray from previous text.e right until even with X3 -> A: oval thick wid A.ht ht A.wid at 2.0*A.wid right of A X0: line thin color gray left 70% from 2mm left of (A.w,A.n) X1: line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<X0,X1>) line thin color gray from previous text.n up until even with X0 -> line thin color gray from previous text.s down until even with X1 -> X2: line thin color gray down 50% from 2mm below (A.w,A.s) X3: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X2,X3>,6/8<X2.start,X2.end>) line thin color gray from previous text.w left until even with X2 -> line thin color gray from previous text.e right until even with X3 -> } set examples(48) { # pikchr.org file doc/ovalobj.md extract 02 A: oval thin dot ".c" below at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw A: oval thin wid A.ht ht A.wid at 2.0*A.wid right of A dot ".c" below at A dot ".n" above at A.n dot " .ne" ljust above at A.ne dot " .e" ljust at A.e dot " .se" ljust below at A.se dot ".s" below at A.s dot ".sw " rjust below at A.sw dot ".w " rjust at A.w dot ".nw " rjust above at A.nw } set examples(49) [UnguardBs { # pikchr.org file doc/pathattr.md extract 01 leftmargin = 1cm A1: arrow thick right 4cm up 3cm dot at A1.start X1: line thin color gray from (0,-3mm) down 0.4cm X2: line same from (4cm,-3mm) down 0.4cm arrow thin color gray from X1 to X2 "4cm" above X3: line same from (4cm+3mm,0) right 0.4cm X4: line same from (4cm+3mm,3cm) right .4cm arrow thin color gray from X3 to X4 "3cm" aligned above X5: line same from A1.start go 4mm heading 90+53.13010235 X6: line same from A1.end go 4mm heading 90+53.13010235 arrow thin color gray from X5 to X6 "5cm" below aligned line same from (0,1cm) up 1cm spline -> from 1.5cm heading 0 from A1.start \\ to 1.5cm heading 10 from A1.start \\ to 1.5cm heading 20 from A1.start \\ to 1.5cm heading 30 from A1.start \\ to 1.5cm heading 40 from A1.start \\ to 1.5cm heading 53.13 from A1.start \\ thin color gray "53.13°" aligned center small }] set examples(50) { # pikchr.org file doc/pathattr.md extract 02 leftmargin = 1cm A1: arrow thick right 4cm then up 3cm dot at A1.start X1: line thin color gray from (0,-3mm) down 0.4cm X2: line same from (4cm,-3mm) down 0.4cm arrow thin color gray from X1 to X2 "4cm" above X3: line same from (4cm+3mm,0) right 0.4cm X4: line same from (4cm+3mm,3cm) right .4cm arrow thin color gray from X3 to X4 "3cm" aligned above } set examples(51) { # pikchr.org file doc/pathattr.md extract 03 box "Origin" Obstacle: oval ht 300% wid 30% with .n at linewid right of Origin.ne; box "Destination" with .nw at linewid right of Obstacle.n line invis from 1st oval.s to 1st oval.n "Obstacle" aligned } set examples(52) [UnguardBs { # pikchr.org file doc/pathattr.md extract 05 box "Origin" Obstacle: oval ht 300% wid 30% with .n at linewid right of Origin.ne; box "Destination" with .nw at linewid right of Obstacle.n line invis from 1st oval.s to 1st oval.n "Obstacle" aligned X: \\ arrow from Origin.s \\ down until even with 1cm below Obstacle.s \\ then right until even with Destination.s \\ then to Destination.s line invis color gray from X.start to 2nd vertex of X \\ "down until even with" aligned small \\ "1cm below Obstacle.s" aligned small line invis color gray from 2nd vertex of X to 3rd vertex of X \\ "right until even with Destination.s" aligned small above line invis color gray from 3rd vertex of X to 4th vertex of X \\ "to Destination.s" aligned small above # Evidence that the alternative arrow is equivalent: assert( 2nd vertex of X == (Origin.s, 1cm below Obstacle.s) ) assert( 3rd vertex of X == (Destination.s, 1cm below Obstacle.s) ) }] set examples(53) [UnguardBs { # pikchr.org file doc/pathattr.md extract 07 line right 2cm then down .5cm then up 1cm right 1cm \\ then up 1cm left 1cm then down .5cm then left 2cm \\ close "with 'close'" dot color red at last line.end move to 2.5cm south of last line.start line right 2cm then down .5cm then up 1cm right 1cm \\ then up 1cm left 1cm then down .5cm then left 2cm \\ then down 1cm "without 'close'" dot color red at last line.end }] set examples(54) { # pikchr.org file doc/place.md extract 01 B: box thick thick color blue circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end¹" fit at 3cm heading 100 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 110 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 270 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 180+75 from B.left arrow thin from previous to B.left chop circle ".start¹" fit at 2.5cm heading 295 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -25 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.6cm heading 180-44 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 2.5cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B } set examples(55) { # pikchr.org file doc/place.md extract 02 B: ellipse thick thick color blue circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end¹" fit at 3cm heading 100 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 110 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 270 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 180+75 from B.left arrow thin from previous to B.left chop circle ".start¹" fit at 2.5cm heading 295 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -25 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.6cm heading 180-44 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 2.5cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B } set examples(56) [UnguardBs { # pikchr.org file doc/place.md extract 03 B: line thick thick color blue go 0.8 heading 350 then go 0.4 heading 120 \\ then go 0.5 heading 35 \\ then go 1.2 heading 190 then go 0.4 heading 340 "+" line thin dashed color gray from B.nw to B.ne to B.se to B.sw close circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end" fit at 2cm heading 120 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 170 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 300 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 280 from B.left arrow thin from previous to B.left chop circle ".start" fit at 2.5cm heading 265 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -15 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.3cm heading 110 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 1.7cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B }] set examples(57) [UnguardBs { # pikchr.org file doc/place.md extract 04 B: line -> thick color blue go 0.8 heading 350 then go 0.4 heading 120 \\ then go 0.5 heading 35 \\ then go 1.2 heading 190 then go 0.4 heading 340 oval "1st vertex" fit at 2cm heading 250 from 1st vertex of B arrow thin from previous to 1st vertex of B chop oval "2nd vertex" fit at 2cm west of 2nd vertex of B arrow thin from previous to 2nd vertex of B chop oval "3rd vertex" fit at 2cm north of 3rd vertex of B arrow thin from previous to 3rd vertex of B chop oval "4th vertex" fit at 2cm east of 4th vertex of B arrow thin from previous to 4th vertex of B chop oval "5th vertex" fit at 2cm east of 5th vertex of B arrow thin from previous to 5th vertex of B chop oval "6th vertex" fit at 2cm heading 200 from 6th vertex of B arrow thin from previous to 6th vertex of B chop }] set examples(58) { # pikchr.org file doc/position.md extract 01 leftmargin = 1cm; P1: dot; text "P1" with .s at 2mm above P1 P2: dot at P1+(2cm,-2cm); text "P2" with .s at 2mm above P2 dot at (P1,P2); text "(P1,P2)" with .s at 2mm above last dot dot at (P2,P1); text "(P2,P1)" with .s at 2mm above last dot } set examples(59) { # pikchr.org file doc/position.md extract 02 P1: dot; text "P1" with .s at 2mm above P1 P2: dot at P1+(4cm,1.5cm); text "P2" with .s at 2mm above P2 line thin color gray dotted from -.5<P1,P2> to 1.5<P1,P2> dot at 3/4<P1,P2>; text "3/4<P1,P2>" at (last dot,P1) arrow thin color gray from last text.n to 1mm south of last dot dot at -0.25 of the way between P1 and P2 text "-0.25 of the way between P1 and P2" at (last dot,P2) arrow thin color gray from last text.s to 1mm north of last dot } set examples(60) { # pikchr.org file doc/stmt.md extract 01 /* 01 */ down /* 02 */ Root: dot "First \"Root\"" above color red /* 03 */ circle wid 50% at Root + (1.5cm, -1.5cm) /* 04 */ arrow dashed from previous to Root chop /* 05 */ Root: 3cm right of Root // Move the location of Root 3cm right /* 06 */ arrow from last circle to Root chop /* 07 */ dot "Second \"Root\"" above color blue at Root } set examples(61) { # pikchr.org file doc/stmt.md extract 03 box "Normal" move box "Double" "Thick" thickness 2*(thickness) } set examples(62) { # pikchr.org file doc/stmt.md extract 04 oval "Hello, World!" fit print "Oval at: ",previous.x, ",", previous.y line oval "2nd oval" fit print "2nd oval at: ",previous.x, ",", previous.y } set examples(63) [UnguardBs { # pikchr.org file tests/narrow.pikchr stickwidth=.045 box height 1 width stickwidth fill 0xC89DC7 move width stickwidth box height 1 width stickwidth fill 0x9FAAD2 move width stickwidth box height 1 width stickwidth fill 0x72B6C0 move width stickwidth box height 1 width stickwidth fill 0x77B89D move width stickwidth box height 1 width stickwidth fill 0xA0B280 move width stickwidth box height 1 width stickwidth fill 0xC5A685 move width stickwidth box height 1 width stickwidth fill 0xD59CA7 move same line <- move same box "Lines should all be" ljust \\ "the same width." ljust \\ "No round-off errors." ljust fit thickness 0 }] set examples(64) { # pikchr.org file doc/homepage.md extract 02 # Same as example 001. arrow right 200% "Markdown" "Source" box rad 10px "Markdown" "Formatter" "(markdown.c)" fit arrow right 200% "HTML+SVG" "Output" arrow <-> down 70% from last box.s box same "Pikchr" "Formatter" "(pikchr.c)" fit } set examples(65) { # pikchr.org file doc/textattr.md extract 01 line "on the line" wid 150% } set examples(66) { # pikchr.org file doc/textattr.md extract 02 line "above" above; move; line "below" below } set examples(67) { # pikchr.org file doc/textattr.md extract 03 line wid 300% "text without \"above\"" "text without \"below\"" } set examples(68) { # pikchr.org file doc/textattr.md extract 04 line width 200% "first above" above "second above" above move line same "first below" below "second below" below } set examples(69) { # pikchr.org file doc/textattr.md extract 05 line wid 200% "ljust" ljust above "rjust" rjust below dot color red at previous.c } set examples(70) { # pikchr.org file doc/textattr.md extract 06 box "ljust" ljust "longer line" ljust "even longer line" ljust fit move box "rjust" rjust "longer line" rjust "even longer line" rjust fit } set examples(71) [UnguardBs { # pikchr.org file doc/textattr.md extract 07 box wid 300% \\ "above-ljust" above ljust \\ "above-rjust" above rjust \\ "centered" center \\ "below-ljust" below ljust \\ "below-rjust" below rjust }] set examples(72) { # pikchr.org file doc/textattr.md extract 08 box "bold" bold "italic" italic "bold-italic" bold italic fit } set examples(73) { # pikchr.org file doc/textattr.md extract 09 box "monospace" monospace fit } set examples(74) { # pikchr.org file doc/textattr.md extract 10 arrow go 150% heading 30 "aligned" aligned above move to 1cm east of previous.end arrow go 150% heading 170 "aligned" aligned above move to 1cm east of previous.end arrow go 150% north "aligned" aligned above } set examples(75) { # pikchr.org file doc/textattr.md extract 11 box ht 200% wid 50% line invis from previous.s to previous.n "rotated text" aligned } set examples(76) [UnguardBs { # pikchr.org file doc/textattr.md extract 12 box "small small" small small "small" small \\ "(normal)" italic \\ "big" big "big big" big big ht 200% }] set examples(77) { # pikchr.org file doc/usepikchr.md extract 03 arrow; box "Hello!"; arrow } set examples(78) { # pikchr.org file doc/usepikchr.md extract 05 arrow; box "Hello" "again"; arrow <- } set examples(79) { # pikchr.org file doc/usepikchr.md extract 06 arrow ->; box "Click to" "toggle"; arrow <- } set examples(80) { # pikchr.org file doc/usepikchr.md extract 07 arrow ->; box "Click to" "toggle" "(centered)"; arrow <- } set examples(81) { # pikchr.org file doc/usepikchr.md extract 09 arrow; ellipse "Hi, Y'all"; arrow } set examples(82) { # pikchr.org file doc/userman.md extract 01 line; box "Hello," "World!"; arrow } set examples(83) [UnguardBs { # pikchr.org file examples/headings01.pikchr # demo label: Cardinal headings linerad = 5px C: circle "Center" rad 150% circle "N" at 1.0 n of C; arrow from C to last chop -> circle "NE" at 1.0 ne of C; arrow from C to last chop <- circle "E" at 1.0 e of C; arrow from C to last chop <-> circle "SE" at 1.0 se of C; arrow from C to last chop -> circle "S" at 1.0 s of C; arrow from C to last chop <- circle "SW" at 1.0 sw of C; arrow from C to last chop <-> circle "W" at 1.0 w of C; arrow from C to last chop -> circle "NW" at 1.0 nw of C; arrow from C to last chop <- arrow from 2nd circle to 3rd circle chop arrow from 4th circle to 3rd circle chop arrow from SW to S chop <-> circle "ESE" at 2.0 heading 112.5 from Center \\ thickness 150% fill lightblue radius 75% arrow from Center to ESE thickness 150% <-> chop arrow from ESE up 1.35 then to NE chop line dashed <- from E.e to (ESE.x,E.y) line dotted <-> thickness 50% from N to NW chop }] set examples(84) { # pikchr.org file doc/userman.md extract 07 down line box "Hello," "World!" arrow } set examples(85) { # pikchr.org file doc/userman.md extract 08 left line box "Hello," "World!" arrow } set examples(86) { # pikchr.org file doc/userman.md extract 09 up line box "Hello," "World!" arrow } set examples(87) { # pikchr.org file doc/userman.md extract 17 A: box dot color red at A.nw ".nw " rjust above dot same at A.w ".w " rjust dot same at A.sw ".sw " rjust below dot same at A.s ".s" below dot same at A.se " .se" ljust below dot same at A.e " .e" ljust dot same at A.ne " .ne" ljust above dot same at A.n ".n" above dot same at A.c " .c" ljust A: circle at 1.5 right of A dot color red at A.nw ".nw " rjust above dot same at A.w ".w " rjust dot same at A.sw ".sw " rjust below dot same at A.s ".s" below dot same at A.se " .se" ljust below dot same at A.e " .e" ljust dot same at A.ne " .ne" ljust above dot same at A.n ".n" above dot same at A.c " .c" ljust A: cylinder at 1.5 right of A dot color red at A.nw ".nw " rjust above dot same at A.w ".w " rjust dot same at A.sw ".sw " rjust below dot same at A.s ".s" below dot same at A.se " .se" ljust below dot same at A.e " .e" ljust dot same at A.ne " .ne" ljust above dot same at A.n ".n" above dot same at A.c " .c" ljust } set examples(88) [UnguardBs { # pikchr.org file doc/userman.md extract 22 B1: box circle at 2cm right of B1 X1: line thin color gray down 50% from 2mm south of B1.s X2: line same from (last circle.s,X1.start) arrow <-> thin from 3/4<X1.start,X1.end> right until even with X2 \\ "2cm" above color gray assert( last arrow.width == 2cm ) }] set examples(89) [UnguardBs { # pikchr.org file doc/userman.md extract 24 B1: box C1: circle with .w at 2cm right of B1.e X1: line thin color gray down 50% from 2mm south of B1.se X2: line same from (C1.w,X1.start) arrow <-> thin from 3/4<X1.start,X1.end> right until even with X2 \\ "2cm" above color gray assert( last arrow.width == 2cm ) }] set examples(90) { # pikchr.org file doc/userman.md extract 36 A: box thick line thin color gray left 70% from 2mm left of A.nw line same from 2mm left of A.sw text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below A.sw X2: line thin color gray down 50% from 2mm below A.se text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> } set examples(91) { # pikchr.org file doc/userman.md extract 37 A: box thick rad 0.3*boxht line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.s) X4: line thin color gray right 70% from A.rad above start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X3) down 30% <- line thin color gray from (previous text,X4) up 30% <- } set examples(92) { # pikchr.org file doc/userman.md extract 38 A: cylinder thick rad 150% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.ne) X4: line thin color gray right 70% from A.rad below start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X4) down 30% <- line thin color gray from (previous text,X3) up 30% <- } set examples(93) { # pikchr.org file doc/userman.md extract 39 A: file thick rad 100% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.n) X4: line thin color gray right 70% from A.rad below start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X4) down 30% <- line thin color gray from (previous text,X3) up 30% <- } set examples(94) { # pikchr.org file doc/userman.md extract 40 A: circle thick rad 120% line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> X3: line thin color gray right 70% from 2mm right of (A.e,A.s) X4: line thin color gray right 70% from A.rad above start of X3 text "radius" at (6/8<X4.start,X4.end>,1/2<X3,X4>) line thin color gray from (previous,X3) down 30% <- line thin color gray from (previous text,X4) up 30% <- line thin color gray <-> from A.sw to A.ne line thin color gray from A.ne go 0.5*A.rad ne then 0.25*A.rad east text " diameter" ljust at end of previous line } set examples(95) { # pikchr.org file doc/userman.md extract 41 A: ellipse thick line thin color gray left 70% from 2mm left of (A.w,A.n) line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<1st line,2ndline>) line thin color gray from previous text.n up until even with 1st line -> line thin color gray from previous text.s down until even with 2nd line -> X1: line thin color gray down 50% from 2mm below (A.w,A.s) X2: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X1,X2>,6/8<X1.start,X1.end>) line thin color gray from previous text.w left until even with X1 -> line thin color gray from previous text.e right until even with X2 -> } set examples(96) { # pikchr.org file doc/userman.md extract 42 A: oval thick X0: line thin color gray left 70% from 2mm left of (A.w,A.n) X1: line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<X0,X1>) line thin color gray from previous text.n up until even with X0 -> line thin color gray from previous text.s down until even with X1 -> X2: line thin color gray down 50% from 2mm below (A.w,A.s) X3: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" at (1/2<X2,X3>,6/8<X2.start,X2.end>) line thin color gray from previous text.w left until even with X2 -> line thin color gray from previous text.e right until even with X3 -> A: oval thick wid A.ht ht A.wid at 2.0*A.wid right of A X0: line thin color gray left 70% from 2mm left of (A.w,A.n) X1: line same from 2mm left of (A.w,A.s) text "height" at (7/8<previous.start,previous.end>,1/2<X0,X1>) line thin color gray from previous text.n up until even with X0 -> line thin color gray from previous text.s down until even with X1 -> X2: line thin color gray down 50% from 2mm below (A.w,A.s) X3: line thin color gray down 50% from 2mm below (A.e,A.s) text "width" small at (1/2<X2,X3>,6/8<X2.start,X2.end>) line thin color gray from previous text.w left until even with X2 -> line thin color gray from previous text.e right until even with X3 -> } set examples(97) { # pikchr.org file doc/userman.md extract 43 diamond "Sharp" "diamond" height 150% move diamond same "“Rounded”" "diamond?" "Sorry; no." rad 150% } set examples(98) { # pikchr.org file doc/userman.md extract 44 down box "Auto-fit text annotation" "as is" fit move 50% box "Auto-fix text annotation" "with 125% width" fit width 125% } set examples(99) { # pikchr.org file doc/userman.md extract 45 boxwid = 0; boxht = 0; box "Hello"; move box "A longer label" "with multiple lines" "of label text" } set examples(100) { # pikchr.org file doc/userman.md extract 46 boxwid = 0 boxht = 0 right box "normal" move box "thin" thin move box "thick" thick move box "thick thick thick" thick thick thick move box "invisible" invisible } set examples(101) { # pikchr.org file doc/userman.md extract 47 boxwid = 0 boxht = 0 box "fully visible" box invisible color gray "outline invisible" box same solid "outline visible again" fit } set examples(102) { # pikchr.org file doc/userman.md extract 48 box "Color: CadetBlue" "Fill: Bisque" fill Bisque color CadetBlue fit move oval "Color: White" "Fill: RoyalBlue" color White fill ROYALBLUE fit } set examples(103) [UnguardBs { # pikchr.org file doc/userman.md extract 49 line go 3cm heading 150 then 3cm west close \\ /* ^^^^^ nota bene! */ \\ fill 0x006000 color White "green" below "triangle" below }] set examples(104) { # pikchr.org file doc/userman.md extract 50 box "box containing" "three lines" "of text" fit move arrow "Labeled" "line" wid 200% } set examples(105) { # pikchr.org file doc/userman.md extract 51 line "on the line" wid 150% } set examples(106) { # pikchr.org file doc/userman.md extract 52 line "above" above; move; line "below" below } set examples(107) { # pikchr.org file doc/userman.md extract 53 line wid 300% "text without \"above\"" "text without \"below\"" } set examples(108) { # pikchr.org file doc/userman.md extract 54 line width 200% "first above" above "second above" above move line same "first below" below "second below" below } set examples(109) { # pikchr.org file doc/userman.md extract 55 line wid 200% "ljust" ljust above "rjust" rjust below dot color red at previous.c } set examples(110) { # pikchr.org file doc/userman.md extract 56 box "ljust" ljust "longer line" ljust "even longer line" ljust fit move box "rjust" rjust "longer line" rjust "even longer line" rjust fit } set examples(111) [UnguardBs { # pikchr.org file doc/userman.md extract 57 box wid 300% \\ "above-ljust" above ljust \\ "above-rjust" above rjust \\ "centered" center \\ "below-ljust" below ljust \\ "below-rjust" below rjust }] set examples(112) { # pikchr.org file doc/userman.md extract 58 box "bold" bold "italic" italic "bold-italic" bold italic fit } set examples(113) { # pikchr.org file doc/userman.md extract 59 box "monospace" monospace fit } set examples(114) { # pikchr.org file doc/userman.md extract 60 arrow go 150% heading 30 "aligned" aligned above move to 1cm east of previous.end arrow go 150% heading 170 "aligned" aligned above move to 1cm east of previous.end arrow go 150% north "aligned" aligned above } set examples(115) { # pikchr.org file doc/userman.md extract 61 box ht 200% wid 50% line invis from previous.s to previous.n "rotated text" aligned } set examples(116) { # pikchr.org file doc/userman.md extract 62 circle "C1" fit circle "C0" at C1+(2.5cm,-0.3cm) fit arrow from C0 to C1 "aligned" aligned above chop } set examples(117) { # pikchr.org file doc/userman.md extract 63 circle "C1" fit circle "C0" at C1+(2.5cm,-0.3cm) fit arrow from C1 to C0 "aligned" aligned above <- chop } set examples(118) [UnguardBs { # pikchr.org file doc/userman.md extract 64 box "small small" small small "small" small \\ "(normal)" italic \\ "big" big "big big" big big ht 200% }] set examples(119) [UnguardBs { # pikchr.org file doc/userman.md extract 65 arrow up 1.5cm right 1.5cm then down .5cm right 1cm then up .5cm right .3cm \\ then down 2.5cm right 1cm "text" box color red thin thin width previous.wid height previous.ht \\ with .c at previous.c dot at last arrow.c color red behind last arrow }] set examples(120) [UnguardBs { # pikchr.org file doc/userman.md extract 66 arrow up 1.5cm right 1.5cm then down .5cm right 1cm then up .5cm right .3cm \\ then down 2.5cm right 1cm box color red thin thin width previous.wid height previous.ht \\ with .c at previous.c dot at last arrow.c color red behind last arrow line invis from 2nd vertex of last arrow to 3rd vertex of last arrow \\ "text" below aligned }] set examples(121) { # pikchr.org file doc/userman.md extract 67 C1: cylinder "text in a" "cylinder" rad 120% dot color red at C1.c dot color blue at 0.75*C1.rad below C1.c } set examples(122) { # pikchr.org file doc/userman.md extract 68 # Deliberate Error: text overflow. FIX: see previous example. C1: cylinder rad 120% text "text in a" "cylinder" at C1.c } set examples(123) { # pikchr.org file doc/userman.md extract 69 A: [ oval "Hello" arrow box "World" radius 4px ] Border: box thin width A.width+0.5in height A.height+0.5in at A.center } set examples(124) { # pikchr.org file doc/userman.md extract 70 A: [ oval "Hello" arrow box "World" radius 4px ] Border: box thin width A.width+0.5in height A.height+0.5in at A.center } set examples(125) { # pikchr.org file doc/userman.md extract 71 A: [ oval "Hello" arrow box "World" radius 4px ] Caption: text "Diagram Caption" italic with .n at 0.1in below A.s } set examples(126) [UnguardBs { # pikchr.org file doc/userman.md extract 05 box "box" circle "circle" at 1 right of previous ellipse "ellipse" at 1 right of previous oval "oval" at 1 right of previous cylinder "cylinder" at .8 below first box file "file" at 1 right of previous diamond "diamond" at 1 right of previous line "line" above from .8 below last cylinder.w arrow "arrow" above from 1 right of previous spline from previous+(1.8cm,-.2cm) \\ go right .15 then .3 heading 30 then .5 heading 160 then .4 heading 20 \\ then right .15 "spline" at 3rd vertex of previous dot at .6 below last line text "dot" with .s at .2cm above previous.n arc from 1 right of previous dot text "arc" at (previous.start, previous.end) text "text" at 1.3 right of start of previous arc }] set examples(127) [UnguardBs { # pikchr.org file examples/objects.pikchr # demo label: Object types AllObjects: [ # First row of objects box "box" box rad 10px "box (with" "rounded" "corners)" at 1in right of previous circle "circle" at 1in right of previous ellipse "ellipse" at 1in right of previous # second row of objects OVAL1: oval "oval" at 1in below first box oval "(tall &" "thin)" "oval" width OVAL1.height height OVAL1.width \\ at 1in right of previous cylinder "cylinder" at 1in right of previous file "file" at 1in right of previous # third row shows line-type objects dot "dot" above at 1in below first oval line right from 1.8cm right of previous "lines" above arrow right from 1.8cm right of previous "arrows" above spline from 1.8cm right of previous \\ go right .15 then .3 heading 30 then .5 heading 160 then .4 heading 20 \\ then right .15 "splines" at 3rd vertex of previous # The third vertex of the spline is not actually on the drawn # curve. The third vertex is a control point. To see its actual # position, uncomment the following line: #dot color red at 3rd vertex of previous spline # Draw various lines below the first line line dashed right from 0.3cm below start of previous line line dotted right from 0.3cm below start of previous line thin right from 0.3cm below start of previous line thick right from 0.3cm below start of previous # Draw arrows with different arrowhead configurations below # the first arrow arrow <- right from 0.4cm below start of previous arrow arrow <-> right from 0.4cm below start of previous # Draw splines with different arrowhead configurations below # the first spline spline same from .4cm below start of first spline -> spline same from .4cm below start of previous <- spline same from .4cm below start of previous <-> ] # end of AllObjects # Label the whole diagram text "Examples Of Pikchr Objects" big bold at .8cm above north of AllObjects }] set examples(128) { # pikchr.org file doc/macro.md extract 01 $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "define-statement" bold fit line down 50% from last box.sw START: dot rad 250% color black X0: last.e move right 3.2in END: box wid 5% ht 25% fill black X9: last.w # The main rule # arrow from X0 right 2*linerad+arrowht oval "\"define\"" fit arrow oval "MACRONAME" fit arrow oval "{...}" fit line right to X9 } set examples(129) [UnguardBs { # pikchr.org file doc/examples.md extract 04 $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "element" bold fit line down 50% from last box.sw dot rad 250% color black X0: last.e + (0.3,0) arrow from last dot to X0 move right 3.9in box wid 5% ht 25% fill black X9: last.w - (0.3,0) arrow from X9 to last box.w # The main rule that goes straight through from start to finish # box "object-definition" italic fit at 11/16 way between X0 and X9 arrow to X9 arrow from X0 to last box.w # The LABEL: rule # arrow right $r from X0 then down 1.25*$r then right $r oval " LABEL " fit arrow 50% oval "\":\"" fit arrow 200% box "position" italic fit arrow line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 arrow from last oval.e right $r*0.5 then up $r*0.8 right $r*0.8 line up $r*0.45 right $r*0.45 then right # The VARIABLE = rule # arrow right $r from X0 then down 2.5*$r then right $r oval " VARIABLE " fit arrow 70% box "assignment-operator" italic fit arrow 70% box "expr" italic fit line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 # The PRINT rule # arrow right $r from X0 then down 3.75*$r then right $r oval "\"print\"" fit arrow box "print-args" italic fit line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 }] set examples(130) [UnguardBs { # pikchr.org file grammar/gram01.pikchr $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "statement-list" bold fit line down 75% from last box.sw dot rad 250% color black X0: last.e + (0.3,0) arrow from last dot to X0 move right 2in box wid 5% ht 25% fill black X9: last.w - (0.3,0) arrow from X9 to last box.w # The main rule that goes straight through from start to finish # box "statement" italic fit at 0.5<X0,X9> arrow to X9 arrow from X0 to last box.w # The by-pass line # arrow right $r from X0 then up $r \\ then right until even with 1/2 way between X0 and X9 line right until even with X9 - ($r,0) \\ then down until even with X9 then right $r # The Loop-back rule # oval "\"\n\"" fit at $r*1.2 below 1/2 way between X0 and X9 line right $r from X9-($r/2,0) then down until even with last oval \\ then to last oval.e -> line from last oval.w left until even with X0-($r,0) \\ then up until even with X0 then right $r oval "\";\"" fit at $r*1.2 below last oval line from 2*$r right of 2nd last oval.e left $r \\ then down until even with last oval \\ then to last oval.e -> line from last oval.w left $r then up until even with 2nd last oval \\ then left 2*$r -> }] set examples(131) [UnguardBs { # pikchr.org file grammar/gram02.pikchr $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "statement" bold fit line down 50% from last box.sw START: dot rad 250% color black X0: last.e move right 4.5in END: box wid 5% ht 25% fill black X9: last.w # The LABEL: rule # arrow right $r from X0 then down 1.25*$r then right $r oval "LABEL" fit arrow 50% oval "\":\"" fit arrow 200% box "position" italic fit arrow line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 arrow from last oval.e right $r*0.5 then up $r*0.8 right $r*0.8 line up $r*0.45 right $r*0.45 then right X2: previous.end # The main top-line rule arrow from START.e to linerad right of X2 box "object-definition" fit arrow to X9 # The VARIABLE = rule # arrow right $r from X0 then down 2.5*$r then right $r oval "VARIABLE" fit arrow 70% box "assignment-operator" italic fit arrow 70% box "expr" italic fit line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 # The macro rule # arrow right $r from X0 then down 3.75*$r then right $r oval "\"define\""fit arrow oval "MACRONAME" fit arrow oval "{...}" fit line right until even with X9-($r,0) \\ then up even with X9 then to X9 # The PRINT rule # arrow right $r from X0 then down 5.0*$r then right $r oval "\"print\"" fit arrow box "print-args" italic fit line right until even with X9 - ($r,0) \\ then up until even with X9 then to X9 # The ASSERT rule # arrow right $r from X0 then down 6.25*$r then right $r oval "\"assert\"" fit arrow 2*arrowht oval "\"(\"" fit A1: arrow right 2*linerad + arrowht box "position" fit arrow 2*arrowht oval "\"==\"" fit arrow 2*arrowht box "position" fit A2: arrow same as A1 oval "\")\"" fit line right even with $r left of X9 then up until even with VARIABLE.n arrow from A1.start right linerad then down 1.25*$r then right linerad+arrowht box "expr" fit arrow 2*arrowht oval "\"==\"" fit arrow same box "expr" fit line right even with linerad right of A2.start \\ then up even with A2 then right linerad }] set examples(132) [UnguardBs { # pikchr.org file grammar/gram03.pikchr $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "object-definition" bold fit line down 50% from last box.sw START: dot rad 250% color black X0: last.e move right 3.2in END: box wid 5% ht 25% fill black X9: last.w # The main rule # arrow from X0 right 2*linerad+arrowht TYPENAME: box "object-type-name" fit # The text-attribute rule # arrow right linerad from X0 then down 1.25*$r then right linerad+arrowht TEXT: box "text-attribute" fit line right even with linerad right of TYPENAME.e \\ then up even with TYPENAME then right linerad X3: previous.end # The attribute loop ATTR: box "attribute" fit with .w at X3 + (2*linerad+arrowht, -1.25*$r) arrow from TYPENAME.e right even with ATTR arrow to X9 arrow from (ATTR.e,X9) right linerad then down even with ATTR then to ATTR.e line from ATTR.w left linerad then up even with X9 then right linerad }] set examples(133) [UnguardBs { # pikchr.org file grammar/gram04.pikchr $r = 0.2in linerad = 0.75*$r linewid = 0.25 # Start and end blocks # box "object-type-name" bold fit line down 50% from last box.sw START: dot rad 250% color black X0: last.e X1: X0+(linerad,0) X2: X1+(linerad+arrowht,0) move right 1.7in END: box wid 5% ht 25% fill black X9: last.w X8: linerad+arrowht west of X9 X7: linerad west of X8 # The choices # arrow from X0 to X2 oval "\"arc\"" fit arrow to X7 arrow to X9 define keyword { right oval $1 fit with .w at 1.25*$r below last oval.w arrow right even with X7 line right even with X8 then up linerad arrow from (X1,last oval.n) down even with last oval then to last oval.w } keyword("\"arrow\"") keyword("\"box\"") keyword("\"circle\"") keyword("\"cylinder\"") keyword("\"dot\"") keyword("\"ellipse\"") keyword("\"file\"") keyword("\"line\"") keyword("\"move\"") keyword("\"oval\"") keyword("\"spline\"") right oval "\"text\"" fit with .w at 1.25*$r below last oval.w arrow right even with X7 line right even with X8 then up even with X9 then right linerad arrow from X0 right even with X1 then down even with last oval \\ then right to last oval.w }] set examples(134) { # pikchr.org file tests/autochop01.pikchr C: box "box" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(135) { # pikchr.org file tests/autochop02.pikchr C: box "box" radius 10px line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(136) { # pikchr.org file tests/autochop03.pikchr C: circle "circle" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(137) { # pikchr.org file tests/autochop04.pikchr C: ellipse "ellipse" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(138) { # pikchr.org file tests/autochop05.pikchr C: oval "oval" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(139) { # pikchr.org file tests/autochop06.pikchr C: cylinder "cylinder" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(140) { # pikchr.org file tests/autochop07.pikchr C: file "file" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(141) [UnguardBs { # pikchr.org file tests/autochop08.pikchr circle "C0" move circle "C1" box at C0.c width 11cm height 2.5cm arrow from C0 to C1 chop color red move text "bug report 2021-07-17" \\ "forum 73eea815afda0715" \\ "arrow C0 to C1 chopped" \\ "C0 and box have same center" \\ at 0.5 between last box.w and C0.w }] set examples(142) [UnguardBs { # pikchr.org file tests/autochop09.pikchr circle "C0" fit color blue C1: circle at C0 radius 2.5*C0.radius color red text "C1" with .n at C1.n color red circle "X1" at 8*C0.radius heading 60 from C0 fit color blue circle "X2" at 8*C0.radius heading 80 from C0 fit color red circle "X3" at 8*C0.radius heading 100 from C0 fit color blue circle "X4" at 8*C0.radius heading 120 from C0 fit color red arrow color blue from C0 to X1 chop arrow color red from C1 to X2 chop arrow color blue from X3 to C0 chop arrow color red from X4 to C1 chop text "chop bug 2021-07-17" \\ "forum 1d46e3a0bc5c5631" \\ "red lines to red circles" \\ "blue lines to blue circle" \\ at 2cm below C0 }] set examples(143) { # pikchr.org file tests/autochop10.pikchr C: diamond "diamond" line from C to 3cm heading 00 from C chop; line from C to 3cm heading 10 from C chop; line from C to 3cm heading 20 from C chop; line from C to 3cm heading 30 from C chop; line from C to 3cm heading 40 from C chop; line from C to 3cm heading 50 from C chop; line from C to 3cm heading 60 from C chop; line from C to 3cm heading 70 from C chop; line from C to 3cm heading 80 from C chop; line from C to 3cm heading 90 from C chop; line from C to 3cm heading 100 from C chop; line from C to 3cm heading 110 from C chop; line from C to 3cm heading 120 from C chop; line from C to 3cm heading 130 from C chop; line from C to 3cm heading 140 from C chop; line from C to 3cm heading 150 from C chop; line from C to 3cm heading 160 from C chop; line from C to 3cm heading 170 from C chop; line from C to 3cm heading 180 from C chop; line from C to 3cm heading 190 from C chop; line from C to 3cm heading 200 from C chop; line from C to 3cm heading 210 from C chop; line from C to 3cm heading 220 from C chop; line from C to 3cm heading 230 from C chop; line from C to 3cm heading 240 from C chop; line from C to 3cm heading 250 from C chop; line from C to 3cm heading 260 from C chop; line from C to 3cm heading 270 from C chop; line from C to 3cm heading 280 from C chop; line from C to 3cm heading 290 from C chop; line from C to 3cm heading 300 from C chop; line from C to 3cm heading 310 from C chop; line from C to 3cm heading 320 from C chop; line from C to 3cm heading 330 from C chop; line from C to 3cm heading 340 from C chop; line from C to 3cm heading 350 from C chop; } set examples(144) { # pikchr.org file tests/colortest1.pikchr box "red" fill red fit move box "orange" fill orange fit move box "yellow" fill yellow fit move box "green" fill green fit move box "blue" fill blue fit move box "violet" fill violet fit box "red" color red fit with .nw at 1cm below 1st box.sw move box "orange" color orange fit move box "yellow" color yellow fit move box "green" color green fit move box "blue" color blue fit move box "violet" color violet fit } set examples(145) { # pikchr.org file tests/diamond01.pikchr D1: diamond "First Diamond" arrow D2: diamond "Above" above "Below" below arrow D3: diamond "Fitted" fit arrow from D2.s down 1cm down D4: diamond "Long string above" above "Below1" below fit right arrow D5: diamond width 300% "thin" fit arrow from D3.e right 2cm right D6: diamond height 300% "tall" above "diamond" below fit } set examples(146) [UnguardBs { # pikchr.org file tests/expr.pikchr linerad = 10px linewid *= 0.5 $h = 0.21 margin = 1cm debug_label_color = Red color = lightgray circle radius 10% OUT: 6.3in right of previous.e # FIX ME IN_X: linerad east of first circle.e # The literal-value line arrow LTV: box "literal-value" fit arrow right even with linerad+2*arrowht east of OUT circle same # The bind-parameter line right BNDP: oval "bind-parameter" fit with .w at 1.25*$h below LTV.w arrow right even with OUT; line right linerad then up linerad arrow from first circle.e right linerad then down even with BNDP \\ then to BNDP.w # The table column reference line right SN: oval "schema-name" fit with .w at 2.0*$h below BNDP.w arrow 2*arrowht oval "." bold fit arrow TN: oval "table-name" fit arrow right 2*arrowht oval "." bold fit arrow CN: oval "column-name" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,SN.n) down even with SN then to SN.w TN_Y: 0.375*$h above TN.n arrow from (IN_X,linerad above TN_Y) down linerad \\ then right even with SN arrow right right even with TN line right even with linerad+arrowht west of CN.w \\ then down even with CN then right linerad line from (linerad+2*arrowht left of TN.w,TN_Y) right linerad \\ then down even with TN then right linerad # Unary operators right UOP: oval "unary-operator" fit with .w at 1.25*$h below SN.w arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,UOP.n) down even with UOP then to UOP.w # Binary operators right BINY: box "expr" fit with .w at 1.25*$h below UOP.w arrow 2*arrowht oval "binary-operator" fit arrow 2*arrowht box "expr" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,BINY.n) down even with BINY then to BINY.w # Function calls right FUNC: oval "function-name" fit with .w at 2.0*$h below BINY.w arrow 1.5*arrowht FLP: oval "(" bold fit arrow FDCT: oval "DISTINCT" fit arrow FEXP: box "expr" fit arrow 150% FRP: oval ")" bold fit arrow right linerad then down $h then right 2*arrowht FFC: box "filter-clause" fit FA1: arrow right linerad then up even with FUNC then right 2*arrowht arrow right linerad then down $h then right 2*arrowht FOC: box "over-clause" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,FUNC.n) down even with FUNC then to FUNC.w # filter clause bypass arrow from FRP.e right even with FFC line to arrowht left of FA1.end # over clause bypass arrow from FA1.end right even with OUT line right linerad then up linerad # expr loop FCMA: oval "," bold fit at 1.25*$h above FEXP arrow from FEXP.e right linerad then up even with FCMA \\ then to FCMA.e line from FCMA.w left even with 2*arrowht west of FEXP.w \\ then down even with FEXP then right linerad # "*" argument list FSTR: oval "*" bold fit with .w at 1.25*$h below FDCT.w arrow from FLP.e right linerad then down even with FSTR \\ then to FSTR.w FA2: arrow from FSTR.e right even with linerad+2*arrowht west of FRP.w line right linerad then up even with FRP then right linerad # empty argument list arrow from (linerad east of FLP.e,FSTR.n) \\ down even with $h below FSTR then right even with FDCT.w arrow right even with FA2.end line right linerad then up even with FSTR.n # parenthesized and vector expressions right PRN: oval "(" bold fit with .w at 3.0*$h below FUNC.w arrow PEXP: box "expr" fit arrow oval ")" bold fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,PRN.n) down even with PRN then to PRN.w # expr loop PCMA: oval "," bold fit at 1.25*$h above PEXP arrow from PEXP.e right linerad then up even with PCMA \\ then to PCMA.e line from PCMA.w left even with 2*arrowht left of PEXP.w \\ then down even with PEXP then right linerad # CAST expression right CAST: oval "CAST" fit with .w at 1.25*$h below PRN.w arrow 2*arrowht oval "(" bold fit arrow 2*arrowht box "expr" fit arrow 2*arrowht oval "AS" fit arrow 2*arrowht box "type-name" fit arrow 2*arrowht oval ")" bold fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,CAST.n) down even with CAST then to CAST.w # COLLATE expression right COLL: box "expr" fit with .w at 1.25*$h below CAST.w arrow 2*arrowht oval "COLLATE" fit arrow 2*arrowht oval "collation-name" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,COLL.n) down even with COLL then to COLL.w # LIKE expressions right LIKE: box "expr" fit with .w at 1.25*$h below COLL.w arrow LNOT: oval "NOT" fit arrow 150% LOP1: oval "LIKE" fit LOP2: oval "GLOB" fit with .w at 1.25*$h below LOP1.w LOP3: oval "REGEXP" fit with .w at 1.25*$h below LOP2.w LOP4: oval "MATCH" fit with .w at 1.25*$h below LOP3.w LE2: box "expr" fit with .w at (4*arrowht+linerad east of LOP3.e,LIKE) arrow from LE2.e right linerad then down $h then right 2*arrowht LESC: oval "ESCAPE" fit arrow 2*arrowht box "expr" fit LA1: arrow right linerad then up even with LIKE then right arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,LIKE.n) down even with LIKE then to LIKE.w # NOT bypass line from linerad*2 west of LNOT.w \\ right linerad then down $h \\ then right even with arrowht east of LNOT.e \\ then up even with LNOT then right linerad # Inputs to the operators LX1: 2*arrowht west of LOP1.w arrow from linerad west of LX1 right linerad \\ then down even with LOP4 then to LOP4.w arrow from (LX1,LOP2.n) down even with LOP2 then to LOP2.w arrow from (LX1,LOP3.n) down even with LOP3 then to LOP3.w # Outputs from the operators LX2: 2*arrowht east of LOP3.e arrow from LOP4.e right even with LX2 arrow right linerad then up even with LE2 then to LE2.w arrow from LOP3.e right even with LX2 line right linerad then up linerad arrow from LOP2.e right even with LX2 line right linerad then up linerad line from LOP1.e to arrowht west of LE2.w # ESCAPE bypass arrow from LE2.e right even with LESC line to arrowht left of LA1.end # ISNULL and NOTNULL operators right NNUL: box "expr" fit with .w at 5.0*$h below LIKE.w arrow NN1: oval "ISNULL" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,NNUL.n) down even with NNUL then to NNUL.w NN2: oval "NOTNULL" fit with .w at 1.25*$h below NN1.w right NN3: oval "NOT" fit with .w at 1.25*$h below NN2.w arrow 2*arrowht NN3B: oval "NULL" fit NNA1: arrow 2*arrowht arrow right linerad then up even with NN1 then right arrow from NN2.e right even with NNA1.end line right linerad then up linerad arrow from NNUL.e right linerad then down even with NN3 then to NN3.w arrow from NNUL.e right linerad then down even with NN2 then to NN2.w # The IS operator right IS: box "expr" fit with .w at 3.75*$h below NNUL.w arrow 2*arrowht oval "IS" fit arrow ISN: oval "NOT" fit arrow box "expr" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,IS.n) down even with IS then to IS.w # NOT bypass line from 3*arrowht west of ISN.w right linerad \\ then down 0.8*$h then right even with arrowht east of ISN.e \\ then up even with ISN then right linerad # The BETWEEN operator right BTW: box "expr" fit with .w at 1.5*$h below IS.w arrow BTWN: oval "NOT" fit arrow oval "BETWEEN" fit arrow 2*arrowht box "expr" fit arrow 2*arrowht oval "AND" fit arrow 2*arrowht box "expr" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,BTW.n) down even with BTW then to BTW.w # NOT bypass line from 3*arrowht west of BTWN.w right linerad \\ then down 0.8*$h then right even with arrowht east of BTWN.e \\ then up even with BTWN then right linerad # The IN operator right IN: box "expr" fit with .w at 1.75*$h below BTW.w arrow INNT: oval "NOT" fit arrow ININ: oval "IN" fit arrow INLP: oval "(" bold fit arrow INSS: box "select-stmt" fit arrow oval ")" bold fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,IN.n) down even with IN then to IN.w # NOT bypass line from 3*arrowht west of INNT.w right linerad \\ then down 0.8*$h then right even with arrowht east of INNT.e \\ then up even with INNT then right linerad # select-stmt bypass line from 3*arrowht west of INSS.w right linerad \\ then up 0.8*$h then right even with arrowht east of INSS.e \\ then up even with INSS then right linerad # expr list instead of select-stmt INE1: box "expr" fit at 1.25*$h below INSS arrow from 3*arrowht west of INSS.w right linerad \\ then down even with INE1 then to INE1.w line from INE1.e right even with arrowht east of INSS.e \\ then up even with INSS then right linerad # expr loop INC1: oval "," bold fit at 1.25*$h below INE1 arrow from INE1.e right linerad then down even with INC1 \\ then to INC1.e line from INC1.w left even with 2*arrowht west of INE1.w \\ then up even with INE1 then right linerad # reference-to-table choice as RHS INSN: oval "schema-name" fit with .w at 4.25*$h below INLP.w arrow from INSN.e right 1.5*arrowht INDT: oval "." bold fit arrow 150% INTF: oval "table-function" fit arrow 1.5*arrowht INL2: oval "(" bold fit arrow 125% INE2: box "expr" fit arrow 125% INR2: oval ")" bold fit arrow right even with OUT; line right linerad then up linerad # table reference branch right INTB: oval "table-name" fit with .w at 2*$h above INTF.w arrow right even with OUT; line right linerad then up linerad arrow from linerad+2*arrowht west of INTF.w right linerad \\ then up even with INTB then to INTB.w # expr-list no table-valued-functions INC2: oval "," bold fit at 1.1*$h above INE2 arrow from INE2.e right linerad then up even with INC2 \\ then to INC2.e line from INC2.w right even with 2*arrowht west of INE2.w \\ then down even with INE2 then right linerad # expr-list bypass for table-valued functions line from INL2.e right linerad then down .7*$h \\ then right even with 2*arrowht left of INR2.w \\ then up even with INR2 then right linerad # links from IN operator to table references arrow from ININ.e right linerad then down even with INSN \\ then to INSN.w # schema-name bypass INY3: 0.45*$h above INSN.n arrow from (linerad east of ININ.e,linerad above INY3) \\ down linerad then right even with arrowht right of INSN.e line right even with arrowht east of INDT.e \\ then down even with INDT then right linerad # NOT? EXISTS? (SELECT) clause right NE: oval "NOT" fit with .w at (IN.w,1.5*$h below INSN) arrow NEE: oval "EXISTS" fit arrow NELP: oval "(" bold fit arrow 2*arrowht box "select-stmt" fit arrow 2*arrowht oval ")" bold fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,NE.n) down even with NE then to NE.w NE_Y: 0.375*$h above NE.n arrow from (IN_X,linerad above NE_Y) down linerad \\ then right even with NE line right even with linerad+arrowht west of NELP.w \\ then down even with NELP then right linerad line from (linerad+2*arrowht left of NEE.w,NE_Y) right linerad \\ then down even with NEE then right linerad # CASE expressions right CS: oval "CASE" fit with .w at 1.25*$h below NE.w arrow CSE1: box "expr" fit arrow 150% CSW: oval "WHEN" fit arrow 2*arrowht CSE2: box "expr" fit arrow 2*arrowht oval "THEN" fit arrow 2*arrowht CSE3: box "expr" fit arrow 200% CSEL: oval "ELSE" fit arrow 2*arrowht CSE4: box "expr" fit arrow oval "END" fit arrow right even with OUT; line right linerad then up linerad arrow from (IN_X,CS.n) down even with CS then to CS.w # first expr bypass CSY: 0.9*$h below CS line from CS.e right linerad then down even with CSY \\ then right even with arrowht east of CSE1.e then up even with CSE1 \\ then right linerad # when clause loop arrow from CSE3.e right linerad then down even with CSY \\ then left even with CSE2 line left even with 2*arrowht west of CSW.w \\ then up even with CSW then right linerad # ELSE clause bypass line from linerad+2*arrowht west of CSEL.w right linerad \\ then down even with CSY then right even with arrowht east of CSE4.e \\ then up even with CSE4 then right linerad # The RAISE function right RSE: box "raise-function" fit with .w at 1.9*$h below CS.w arrow right even with OUT; line right linerad then up even with first circle then right linerad arrow from (IN_X,BNDP.n) down even with RSE then to RSE.w }] set examples(147) [UnguardBs { # pikchr.org file tests/fonts01.pikchr ROW1: \\ box "left" ljust \\ "normal text"\\ "right" rjust fit box "left" ljust italic \\ "italic text" italic \\ "right" rjust italic fit box "left" ljust bold \\ "bold text" bold \\ "right" rjust bold fit box "left" ljust mono \\ "monospace text" monospace \\ "right" rjust mono fit ROW2: \\ box "left" ljust bold italic\\ "bold italic text" italic bold \\ "right" rjust italic bold fit with nw at ROW1.sw box "left" ljust bold mono \\ "bold monospace text" mono bold \\ "right" rjust monospace bold fit box "left" ljust italic mono \\ "italic monospace text" mono italic \\ "right" rjust monospace italic fit ROW3: \\ box "left" ljust bold italic mono \\ "bold italic text" italic monospace bold \\ "right" rjust monospace italic bold fit with nw at ROW2.sw ROW4: \\ box "left" ljust big \\ "normal big text" big\\ "right" rjust big fit with nw at ROW3.sw box "left" ljust italic big \\ "big italic text" italic big \\ "right" rjust italic big fit box "left" big ljust bold \\ "big bold text" big bold \\ "right" rjust big bold fit box "left" ljust big mono \\ "big monospace text" big monospace \\ "right" rjust mono big fit ROW5: \\ box "left" ljust big bold italic\\ "big bold italic text" big italic bold \\ "right" rjust italic bold big fit with nw at ROW4.sw box "left" ljust bold mono big \\ "big bold monospace text" mono big bold \\ "right" rjust monospace bold big fit box "left" ljust italic mono big \\ "big italic monospace text" mono big italic \\ "right" rjust monospace italic big fit ROW6: \\ box "left" ljust bold italic big mono \\ "big bold italic mono text" italic monospace big bold \\ "right" rjust monospace italic bold big fit with nw at ROW5.sw }] set examples(148) { # pikchr.org file tests/test01.pikchr right; circle "C0"; A0: arrow; circle "C1"; A1: arrow; circle "C2"; arrow; circle "C4"; arrow; circle "C6" circle "C3" at (C4.x-C2.x) ne of C2; arrow; circle "C5" arrow from C2.ne to C3.sw assert( previous == last arrow ) assert( previous == 6th arrow ) # Demonstrate that a new point can be established using LABEL: notation AS: start of last arrow AE: end of last arrow # Validate various kinds of expressions and locations as a test of # parser expression processing and layout # assert( last arrow.start.x == C2.ne.x ) assert( AS.y == C2.ne.y ) assert( last arrow.end.x == C3.sw.x ) assert( AE.y == C3.sw.y ) assert( AE == C3.sw ) assert( 1st last arrow.end == C3.sw ) assert( start of A0 == C0.e ) assert( C0.y == C1.y ); assert( C0.y == C2.y ); assert( C0.y == C4.y ); assert( C0.y == C6.y ); assert( C3.y == C5.y ); } set examples(149) [UnguardBs { # pikchr.org file tests/test02.pikchr /* First generate the main graph */ scale = 0.75 Main: [ circle "C0" arrow circle "C1" arrow circle "C2" arrow circle "C4" arrow circle "C6" ] Branch: [ circle "C3" arrow circle "C5" ] with .sw at Main.C2.n + (0.35,0.35) arrow from Main.C2 to Branch.C3 chop /* Now generate the background colors */ layer = 0 $featurecolor = 0xfedbce $maincolor = 0xd9fece $divY = (Branch.y + Main.y)/2 $divH = (Branch.y - Main.y) box fill $featurecolor color $featurecolor \\ width Branch.width*1.5 height $divH \\ at Branch box fill $maincolor color $maincolor \\ width Main.width+0.1 height $divH \\ at Main "main" ljust at 0.1 se of nw of 2nd box "feature" ljust at 0.1 se of nw of 1st box }] set examples(150) [UnguardBs { # pikchr.org file doc/teardown01.md extract 01 /* 01 */ scale = 0.8 /* 02 */ fill = white /* 03 */ linewid *= 0.5 /* 04 */ circle "C0" fit /* 05 */ circlerad = previous.radius /* 06 */ arrow /* 07 */ circle "C1" /* 08 */ arrow /* 09 */ circle "C2" /* 10 */ arrow /* 11 */ circle "C4" /* 12 */ arrow /* 13 */ circle "C6" /* 14 */ circle "C3" at dist(C2,C4) heading 30 from C2 /* 15 */ arrow /* 16 */ circle "C5" /* 17 */ arrow from C2 to C3 chop /* 18 */ C3P: circle "C3'" at dist(C4,C6) heading 30 from C6 /* 19 */ arrow right from C3P.e /* 20 */ C5P: circle "C5'" /* 21 */ arrow from C6 to C3P chop /* 22 */ box height C3.y-C2.y \\ /* 23 */ width (C5P.e.x-C0.w.x)+linewid \\ /* 24 */ with .w at 0.5*linewid west of C0.w \\ /* 25 */ behind C0 \\ /* 26 */ fill 0xc6e2ff thin color gray /* 27 */ box same width previous.e.x - C2.w.x \\ /* 28 */ with .se at previous.ne \\ /* 29 */ fill 0x9accfc /* 30 */ "trunk" below at 2nd last box.s /* 31 */ "feature branch" above at last box.n }] set examples(151) [UnguardBs { # pikchr.org file tests/test58.pikchr scale = 0.8 All: [ circle "C0" fit fill white arrow right 50% $arrowlen = previous.wid circle same "C1" A1: arrow same thickness 0.5*(thickness) # ^^^^^^^^^^^^^^^ # demonstrate access to the "thickness" variable by # enclosing it in parentheses circle same "C2" arrow same as 1st arrow circle same "C4" arrow same circle same "C6" circle same "C3" at dist(C2,C4) heading 30 from C2 arrow right 50% circle same "C5" arrow from C2 to C3 chop C3P: circle same "C3'" at dist(C4,C6) heading 30 from C6 arrow right 50% from C3P.e C5P: circle same "C5'" arrow from C6 to C3P chop box height C3.y-C2.y \\ width dist(C5P.e,C0.w)+1.5*C1.rad \\ with .w at 0.5*$arrowlen west of C0.w \\ behind C0 \\ fill 0xc6e2ff color 0xaac5df box same width previous.e.x - C2.w.x \\ with .se at previous.ne \\ fill 0x9accfc spline <- thin from 1mm south of A1.center down .8cm then right .5cm color gray " 0.5*(thickness)" ljust small at previous.end dot at previous.c assert( A1.thickness == 1st arrow.thickness/2 ) right circle "C0" fit fill white at 3.5cm south of C0 arrow right 50% circle same "C1" arrow same circle same "C2" arrow same circle same "C4" arrow same circle same "C6" circle same "C3" at dist(C2,C4) heading 30 from C2 arrow right 50% circle same "C5" arrow same circle same "C7" arrow from C2 to C3 chop arrow from C6 to C7 chop box height C3.y-C2.y \\ width dist(C7.e,C0.w)+1.5*C1.radius \\ with .w at 0.5*$arrowlen west of C0.w \\ behind C0 \\ fill 0xc6e2ff color 0xaac5df box same width previous.e.x - C2.w.x \\ with .se at previous.ne \\ fill 0x9accfc ] "Rebase vs. Merge" big big bold with .s at 3mm north of All.n }] set examples(152) [UnguardBs { # pikchr.org file tests/test03.pikchr right B1: box "One"; line B2: box "Two"; arrow B3: box "Three"; down; arrow down 50%; circle "Hi!"; left; spline -> left 2cm then to One.se Macro: [ B4: box "four" B5: box "five" B6: box "six" ] with n at 3cm below s of 2nd box arrow from s of 2nd box to Macro.B5.n spline -> from e of last circle right 1cm then down 1cm then to Macro.B4.e box width Macro.width+0.1 height Macro.height+0.1 at Macro color Red box width Macro.B5.width+0.05 \\ height Macro.B5.height+0.05 at Macro.B5 color blue }] set examples(153) { # pikchr.org file tests/test06.pikchr B1: box "one" width 1 height 1 at 2,2; B2: box thickness 300% dotted 0.03 "two" at 1,3; print "B2.n: ",B2.n.x,",",B2.n.y print "B2.c: ",B2.c.x,",",B2.c.y print "B2.e: ",B2.e.x,",",B2.e.y scale = 1 box "three" "four" ljust "five" with .n at 0.1 below B2.s width 50% # Text demo: <text x="100" y="100" text-anchor="end" dominant-baseline="central">I love SVG!</text> } set examples(154) { # pikchr.org file tests/test07.pikchr B: box "This is" "<b>" "box \"B\"" color DarkRed "B.nw" rjust above at 0.05 left of B.nw "B.w" rjust at 0.05 left of B.w "B.sw" rjust below at 0.05 left of B.sw; $abc = DarkBlue "B.s" below at B.s // C++ style comments allowed. "B.se" ljust below at 0.05 right of B.se color DarkBlue "B.e" ljust at 0.05 right of B.e /* C-style comments */ "B.ne" ljust above at 0.05 right of B.ne "B.n" center above at B.n print "this is a test: " /*comment ignored*/, $abc print "Colors:", Orange, Black, White, Red, Green, Blue # line from B.ne + (0.05,0) right 1.0 then down 2.5 then left 1.5 } set examples(155) [UnguardBs { # pikchr.org file tests/test08.pikchr debug = 1; box "one" width 80% height 80% box "two" width 150% color DarkRed # Comment does not mask newline arrow "xyz" above // Comment does not mask newline box "three" height 150% color DarkBlue down arrow B4: box "four" B45: box "4.5" fill SkyBlue move B5: box "five" left B6: box "six" up box "seven" width 50% height 50% line from 0.1 right of B4.e right 1 then down until even with B5 \\ then to B5 rad 0.1 chop arrow from B6 left even with 2nd box then up to 2nd box chop rad 0.1 arrow from 1/2 way between B6.w and B6.sw left until even with first box \\ then up to first box rad 0.1 chop oval wid 25% ht B4.n.y - B45.s.y at (B6.x,B4.s.y) arrow from last box to last oval chop arrow <- from B4.w left until even with last oval.e arrow <- from B45 left until even with last oval.e chop }] set examples(156) { # pikchr.org file tests/test10.pikchr C: "+"; $x = 0 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C $x = $x + 10 line from 0.5 heading $x from C to 1.0 heading $x from C } set examples(157) { # pikchr.org file tests/test12.pikchr circle "One" arrow circle "Two"; down arrow down 40% circle "Three" move circle "Four" } set examples(158) { # pikchr.org file tests/test13.pikchr // margin = 1 line up 1 right 2 linewid = 0 arrow left 2 move left 0.1 line <-> down 1 "height " rjust } set examples(159) { # pikchr.org file tests/test14.pikchr print "1in=",1in print "1cm=",1cm print "1mm=",1mm print "1pt=",1pt print "1px=",1px print "1pc=",1pc scale = 0.25 circle "in" radius 1in circle "cm" radius 2.54cm circle "mm" radius 25.4mm circle "pt" radius 72pt circle "px" radius 96px circle "pc" radius 6pc circle "in" radius 0.5*1in with .n at s of 1st circle circle "cm" radius 0.5*2.54cm circle "mm" radius 25.4mm * 0.5 circle "pt" radius 72pt * 0.5 circle "px" radius 96px * 0.5 circle "pc" radius 6pc * 0.5 } set examples(160) { # pikchr.org file tests/test15.pikchr ellipse "document" arrow box "PIC" arrow box "TBL/EQN" "(optional)" dashed arrow box "TROFF" arrow ellipse "typesetter" } set examples(161) { # pikchr.org file tests/test16.pikchr box "this is" "a box" } set examples(162) { # pikchr.org file tests/test17.pikchr line "this is" "a line" } set examples(163) { # pikchr.org file tests/test22.pikchr box invisible "input"; arrow; box invisible "output" } set examples(164) { # pikchr.org file tests/test23.pikchr margin = 24pt; linewid *= 1.75 arrow "on top of"; move arrow "above" "below"; move arrow "above" above; move arrow "below" below; move arrow "above" "on top of" "below" move to start of first arrow down 1in; right arrow "way above" "above" "on the line" "below" "way below" move; arrow "way above" "above" "below" "way below" move to start of first arrow down 2in; right box "first line" "second line" "third line" "fourth line" "fifth line" fit move box "first line" "second line" "third line" "fourth line" fit move box "first line" "second line" "third line" fit move box "first line" "second line" fit move box "first line" fit move to start of first arrow down 3in; right box "first above" above "second above" above "third" fit dot color red at last box move 2cm box " 3 leading spaces" "&" "3 trailing spaces " fit } set examples(165) { # pikchr.org file tests/test23b.pikchr margin = 24pt; linewid *= 1.75 charht = 0.14 //thickness *= 8 print charht, thickness arrow "on top of"; move arrow "above" "below"; move arrow "above" above; move arrow "below" below; move arrow "above" "on top of" "below" move to start of first arrow down 1in; right arrow "way a||bove" "ab||ove" "on t||he line" "below" "way below" move; arrow "way above" "above" "below" "way below" move; arrow "way above" above "above" above move; arrow "below" below "way below" below move; arrow "above-1" above "above-2" above "floating" move to start of first arrow down 2in; right arrow "above-1" above "above-2" above "below" below move; arrow "below-1" below "below-2" below "floating" move; arrow "below-1" below "below-2" below "above" above move to start of first arrow down 3in; right box "first line" "second line" "third line" "fourth line" "fifth line" fit move box "first line" "second line" "third line" "fourth line" fit move box "first line" "second line" "third line" fit move box "first line" "second line" fit move box "first line" fit move to start of first arrow down 4in; right box "first above" above "second above" above "third" fit dot color red at last box } set examples(166) { # pikchr.org file tests/test23c.pikchr linewid *= 2 arrow "Big" big "Small" small thin box invis "thin" "line" fit move arrow "Big Big" big big "Small Small" small small thick box invis "thick" "line" fit box thick "Thick" with .nw at .5 below start of 1st arrow move box thick thick "Thick" "Thick" move box thin "Thin" move box thin thin "Thin" "Thin" } set examples(167) { # pikchr.org file tests/test28.pikchr box "Box" arrow cylinder "One" down arrow ellipse "Ellipse" up arrow from One.n circle "Circle" right arrow from One.e <- circle "E" radius 50% circle "NE" radius 50% at 0.5 ne of One.ne arrow from NE.sw to One.ne circle "SE" radius 50% at 0.5 se of One.se arrow from SE.nw to One.se spline from One.sw left 0.2 down 0.2 then to Box.se -> spline from Circle.w left 0.3 then left 0.2 down 0.2 then to One.nw -> } set examples(168) [UnguardBs { # pikchr.org file tests/test29.pikchr # Demonstrate the ability to close and fill a line with the "fill" # attribute - treating it as a polygon. # line right 1 then down 0.25 then up .5 right 0.5 \\ then up .5 left 0.5 then down 0.25 then left 1 close fill blue move box "Box to right" "of the" "polygon" move line "not a" "polygon" right 1in fill red move to w of 1st line then down 3.5cm line same as 1st line }] set examples(169) { # pikchr.org file tests/test31.pikchr box "1" [ box "2"; arrow "3" above; box "4" ] with .n at last box.s - (0,0.1) "Thing 2: " rjust at last [].w dot at last box.s color red dot at last [].n color blue } set examples(170) { # pikchr.org file tests/test36.pikchr h = .5; dh = .02; dw = .1 [ Ptr: [ boxht = h; boxwid = dw A: box B: box C: box box wid 2*boxwid "..." D: box ] Block: [ boxht = 2*dw; boxwid = 2*dw movewid = 2*dh A: box; move B: box; move C: box; move box invis "..." wid 2*boxwid; move D: box ] with .n at Ptr.s - (0,h/2) arrow from Ptr.A to Block.A.nw + (dh,0) arrow from Ptr.B to Block.B.nw + (dh,0) arrow from Ptr.C to Block.C.nw + (dh,0) arrow from Ptr.D to Block.D.nw + (dh,0) ] box dashed ht last [].ht+dw wid last [].wid+dw at last [] } set examples(171) { # pikchr.org file tests/test37.pikchr # Change from the original: # Need fixing: # * "bottom of last box" # * ".t" # define ndblock { box wid boxwid/2 ht boxht/2 down; box same with .t at bottom of last box; box same } boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05 down; box; box; box; box ht 3*boxht "." "." "." L: box; box; box invis wid 2*boxwid "hashtab:" with .e at 1st box .w right Start: box wid .5 with .sw at 1st box.ne + (.4,.2) "..." N1: box wid .2 "n1"; D1: box wid .3 "d1" N3: box wid .4 "n3"; D3: box wid .3 "d3" box wid .4 "..." N2: box wid .5 "n2"; D2: box wid .2 "d2" arrow right from 2nd box ndblock spline -> right .2 from 3rd last box then to N1.sw + (dx,0) spline -> right .3 from 2nd last box then to D1.sw + (dx,0) arrow right from last box ndblock spline -> right .2 from 3rd last box to N2.sw-(dx,.2) to N2.sw+(dx,0) spline -> right .3 from 2nd last box to D2.sw-(dx,.2) to D2.sw+(dx,0) arrow right 2*linewid from L ndblock spline -> right .2 from 3rd last box to N3.sw + (dx,0) spline -> right .3 from 2nd last box to D3.sw + (dx,0) circlerad = .3 circle invis "ndblock" at last box.e + (1.2,.2) arrow dashed from last circle.w to 5/8<last circle.w,2nd last box> chop box invis wid 2*boxwid "ndtable:" with .e at Start.w } set examples(172) { # pikchr.org file tests/test38.pikchr # Deliberate Error: text overflow. FIX: see next example. # Need fixing: # # * ".bot" as an abbreviation for ".bottom" # * "up from top of LA" # arrow "source" "code" LA: box "lexical" "analyzer" arrow "tokens" above P: box "parser" arrow "intermediate" "code" Sem: box "semantic" "checker" arrow arrow <-> up from top of LA LC: box "lexical" "corrector" arrow <-> up from top of P Syn: box "syntactic" "corrector" arrow up DMP: box "diagnostic" "message" "printer" arrow <-> right from east of DMP ST: box "symbol" "table" arrow from LC.ne to DMP.sw arrow from Sem.nw to DMP.se arrow <-> from Sem.top to ST.bot } set examples(173) { # pikchr.org file tests/test38b.pikchr # Need fixing: # # * ".bot" as an abbreviation for ".bottom" # * "up from top of LA" # arrow "source" "code" LA: box "lexical" "analyzer" arrow "tokens" above P: box "parser" arrow "intermediate" "code" wid 180% Sem: box "semantic" "checker" arrow arrow <-> up from top of LA LC: box "lexical" "corrector" arrow <-> up from top of P Syn: box "syntactic" "corrector" arrow up DMP: box "diagnostic" "message" "printer" arrow <-> right from east of DMP ST: box "symbol" "table" arrow from LC.ne to DMP.sw arrow from Sem.nw to DMP.se arrow <-> from Sem.top to ST.bot } set examples(174) { # pikchr.org file doc/examples.md extract 09 arrow "source" "code" LA: box "lexical" "analyzer" arrow "tokens" above P: box "parser" arrow "intermediate" "code" wid 200% Sem: box "semantic" "checker" arrow arrow <-> up from top of LA LC: box "lexical" "corrector" arrow <-> up from top of P Syn: box "syntactic" "corrector" arrow up DMP: box "diagnostic" "message" "printer" arrow <-> right from east of DMP ST: box "symbol" "table" arrow from LC.ne to DMP.sw arrow from Sem.nw to DMP.se arrow <-> from Sem.top to ST.bot } set examples(175) { # pikchr.org file tests/test41.pikchr # Corner test box "C" $d = 1in circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop box "C" at 3*$d east of C radius 15px circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop ellipse "C" at 2.5*$d south of 1st box circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop circle "C" at 3*$d east of last ellipse circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop cylinder "C" at 2.5*$d south of last ellipse circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop oval "C" at 3*$d east of last cylinder circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop file "C" at 2.5*$d south of last cylinder circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop diamond "C" at 2.5*$d south of last oval circle rad 50% "N" at $d n of C; arrow from last circle to C.n chop circle same "NE" at $d ne of C; arrow from last circle to C.ne chop circle same "E" at $d e of C; arrow from last circle to C.e chop circle same "SE" at $d se of C; arrow from last circle to C.se chop circle same "S" at $d s of C; arrow from last circle to C.s chop circle same "SW" at $d sw of C; arrow from last circle to C.sw chop circle same "W" at $d w of C; arrow from last circle to C.w chop circle same "NW" at $d nw of C; arrow from last circle to C.nw chop } set examples(176) { # pikchr.org file tests/test42.pikchr C: ellipse "ellipse" line from C to 2cm heading 00 from C chop; line from C to 2cm heading 10 from C chop; line from C to 2cm heading 20 from C chop; line from C to 2cm heading 30 from C chop; line from C to 2cm heading 40 from C chop; line from C to 2cm heading 50 from C chop; line from C to 2cm heading 60 from C chop; line from C to 2cm heading 70 from C chop; line from C to 2cm heading 80 from C chop; line from C to 2cm heading 90 from C chop; line from C to 2cm heading 100 from C chop; line from C to 2cm heading 110 from C chop; line from C to 2cm heading 120 from C chop; line from C to 2cm heading 130 from C chop; line from C to 2cm heading 140 from C chop; line from C to 2cm heading 150 from C chop; line from C to 2cm heading 160 from C chop; line from C to 2cm heading 170 from C chop; line from C to 2cm heading 180 from C chop; line from C to 2cm heading 190 from C chop; line from C to 2cm heading 200 from C chop; line from C to 2cm heading 210 from C chop; line from C to 2cm heading 220 from C chop; line from C to 2cm heading 230 from C chop; line from C to 2cm heading 240 from C chop; line from C to 2cm heading 250 from C chop; line from C to 2cm heading 260 from C chop; line from C to 2cm heading 270 from C chop; line from C to 2cm heading 280 from C chop; line from C to 2cm heading 290 from C chop; line from C to 2cm heading 300 from C chop; line from C to 2cm heading 310 from C chop; line from C to 2cm heading 320 from C chop; line from C to 2cm heading 330 from C chop; line from C to 2cm heading 340 from C chop; line from C to 2cm heading 350 from C chop; } set examples(177) [UnguardBs { # pikchr.org file tests/test43.pikchr scale = 0.75 box "One" arrow right 200% "Bold" bold above "Italic" italic below circle "Two" circle "Bold-Italic" bold italic aligned fit \\ at 4cm heading 143 from Two arrow from Two to last circle "above" aligned above "below" aligned below chop circle "C2" fit at 4cm heading 50 from Two arrow from Two to last circle "above" aligned above "below "aligned below chop circle "C3" fit at 4cm heading 200 from Two arrow from last circle to Two <- \\ "above-rjust" aligned rjust above \\ "below-rjust" aligned rjust below chop }] set examples(178) { # pikchr.org file tests/test44.pikchr debug=1 file "*.md" rad 20% arrow box rad 10px "Markdown" "Interpreter" arrow right 120% "HTML" above file " HTML " } set examples(179) [UnguardBs { # pikchr.org file tests/test45.pikchr # Deliberate Error: slight text overflow "ljust" ALL: [ file "ljust" italic "*.md" ljust "*.txt" ljust "*.wiki" ljust rad 20% arrow box rad 10px "Markdown" mono ljust "Interpreter" monospace ljust \\ "(monospace)" mono ljust italic fit arrow right 200% "above" above "rjust " rjust below " ljust" ljust below file "rjust" italic "*.htm" rjust "*.js" rjust arrow down from first box.s "rjust " rjust " ljust" ljust box "rjust" rjust above "center" center "ljust" ljust above \\ "rjust" rjust below "ljust" ljust below big big ] box invis "Text Justification Rules" big bold fit with .s at 0.2 above ALL.n }] set examples(180) [UnguardBs { # pikchr.org file tests/test46.pikchr # Test case for all production rule: # # position ::= object edge # All: [ B: box dashed circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end¹" fit at 3cm heading 100 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 110 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 270 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 180+75 from B.left arrow thin from previous to B.left chop circle ".start¹" fit at 2.5cm heading 295 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -25 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.6cm heading 180-44 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 2.5cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B ] "21 Names For 9 Boundary Points" big big with .s at .5cm above All.n "¹ \"start\" and \"end\" assume a \"right\" layout direction" below \\ with .n at 2mm below All.s }] set examples(181) [UnguardBs { # pikchr.org file tests/test47.pikchr # Test case for all production rule: # # position ::= object edge # All: [ B: line thick thick color blue go 0.8 heading 350 then go 0.4 heading 120 \\ then go 0.5 heading 35 \\ then go 1.2 heading 190 then go 0.4 heading 340 "+" line thin dashed color gray from B.nw to B.ne to B.se to B.sw close circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end" fit at 2cm heading 120 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 170 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 300 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 280 from B.left arrow thin from previous to B.left chop circle ".start" fit at 2.5cm heading 265 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -15 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.3cm heading 110 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 1.7cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B ] "21 Names For 11 Boundary Points" big big with .s at .5cm above All.n }] set examples(182) [UnguardBs { # pikchr.org file tests/test47b.pikchr # Test case for all production rule: # # position ::= object edge # All: [ B: line thick thick color blue go 0.8 heading 350 then go 0.4 heading 120 \\ then go 0.5 heading 35 \\ then go 1.2 heading 190 then go 0.4 heading 340 close "+" line thin dashed color gray from B.nw to B.ne to B.se to B.sw close circle ".n" fit at 1.5cm heading 0 from B.n arrow thin from previous to B.n chop circle ".north" fit at 3cm heading 15 from B.north arrow thin from previous to B.north chop circle ".t" fit at 1.5cm heading 30 from B.t arrow thin from previous to B.t chop circle ".top" fit at 3cm heading -15 from B.top arrow thin from previous to B.top chop circle ".ne" fit at 1cm ne of B.ne; arrow thin from previous to B.ne chop circle ".e" fit at 2cm heading 50 from B.e; arrow thin from previous to B.e chop circle ".right" fit at 3cm heading 75 from B.right arrow thin from previous to B.right chop circle ".end" fit at 2cm heading 95 from B.end arrow thin from previous to B.end chop circle ".se" fit at 1cm heading 170 from B.se arrow thin from previous to B.se chop circle ".s" fit at 1.5cm heading 180 from B.s arrow thin from previous to B.s chop circle ".south" fit at 3cm heading 195 from B.south arrow thin from previous to B.south chop circle ".bot" fit at 1.8cm heading 215 from B.bot arrow thin from previous to B.bot chop circle ".bottom" fit at 2.7cm heading 160 from B.bottom arrow thin from previous to B.bottom chop circle ".sw" fit at 1cm sw of B.sw; arrow thin from previous to B.sw chop circle ".w" fit at 2cm heading 300 from B.w arrow thin from previous to B.w chop circle ".left" fit at 3cm heading 280 from B.left arrow thin from previous to B.left chop circle ".start" fit at 2.5cm heading 265 from B.start arrow thin from previous to B.start chop circle ".nw" fit at 1cm nw of B.nw; arrow thin from previous to B.nw chop circle ".c" fit at 2.5cm heading -15 from B.c line thin from previous to 0.5<previous,B.c> chop arrow thin from previous.end to B.c circle ".center" fit at 3.3cm heading 130 from B.center line thin from previous to 0.5<previous,B.center> chop arrow thin from previous.end to B.center circle "λ" fit at 1.7cm heading 250 from B line from previous to 0.5<previous,B> chop arrow thin from previous.end to B ] "21 Names For 11 Boundary Points" big big above \\ "On a closed polygon" above with .s at 0.2cm below All.n }] set examples(183) [UnguardBs { # pikchr.org file tests/test48.pikchr # Test case for all production rule: # # position ::= object edge # All: [ B: line thick color blue go 0.8 heading 350 then go 0.4 heading 120 \\ then go 0.5 heading 35 \\ then go 1.2 heading 190 then go 0.4 heading 340 "+" oval "1st vertex" fit at 2cm heading 250 from 1st vertex of B arrow thin from previous to 1st vertex of B chop oval "2nd vertex" fit at 2cm west of 2nd vertex of B arrow thin from previous to 2nd vertex of B chop oval "3rd vertex" fit at 2cm north of 3rd vertex of B arrow thin from previous to 3rd vertex of B chop oval "4th vertex" fit at 2cm east of 4th vertex of B arrow thin from previous to 4th vertex of B chop oval "5th vertex" fit at 2cm east of 5th vertex of B arrow thin from previous to 5th vertex of B chop oval "6th vertex" fit at 2cm south of 6th vertex of B arrow thin from previous to 6th vertex of B chop ] "Names Of Vertexes" big big with .s at .5cm above All.n }] set examples(184) { # pikchr.org file tests/test49.pikchr dot "A" above dot "B" above at 3 heading 130 from A dot "(A,B)" above at (A,B) dot "(B,A)" above at (B,A) } set examples(185) [UnguardBs { # pikchr.org file tests/test50.pikchr All: [ CW: box "cwal" line <- S2: box "s2" line <- CL: box "client" arc -> color red cw from CL.s to CW.s ] text "Red arc is fully visible" "Pikchr forum 2020-09-14" \\ with .s at 5mm above All.n }] set examples(186) [UnguardBs { # pikchr.org file tests/test51.pikchr One: [ CW: box "cwal" line <- S2: box "s2" line <- CL: box "client" down line -> line -> left until even with CW line -> color red go up to CW.s ] text "Red line should be an arrow" "Pikchr forum 2020-09-14" \\ with .s at 2mm above One.n Two: [ right CW: box "cwal" line <- S2: box "s2" line <- CL: box "client" down line -> line -> left until even with CW up line -> to CW.s color red ] with .n at 1cm below One.s }] set examples(187) { # pikchr.org file tests/test52.pikchr All: [ file "A" cylinder "B" at 5cm heading 125 from A X: line from A to B chop "from A to B" aligned above dot color red at X.c dot color red at X.start dot color red at X.end ] "Text Alignment" big "On A Chopped Line" big with .s at .3cm above All.n } set examples(188) { # pikchr.org file tests/test53.pikchr line color green dot color red line color blue text "\"dot\" object causes no motion" with .s at 8mm above last dot assert( 1st dot.start == 1st dot.end ) assert( 1st line.end == 2nd line.start ) } set examples(189) [UnguardBs { # pikchr.org file tests/test55.pikchr lineht *= 0.4 $margin = lineht*2.5 # scale = 0.5 # fontscale = 1.125 down In: box "Interface" wid 150% ht 75% fill white arrow CP: box same "SQL Command" "Processor" arrow VM: box same "Virtual Machine" arrow down 1.25*$margin BT: box same "B-Tree" arrow box same "Pager" arrow OS: box same "OS Interface" box same with .w at 1.25*$margin east of 1st box.e "Tokenizer" arrow box same "Parser" arrow CG: box same ht 200% "Code" "Generator" UT: box same as 1st box at (Tokenizer,Pager) "Utilities" move lineht TC: box same "Test Code" arrow from CP to 1/4<Tokenizer.sw,Tokenizer.nw> chop arrow from 1/3<CG.nw,CG.sw> to CP chop box ht (In.n.y-VM.s.y)+$margin wid In.wid+$margin \\ at CP fill 0xd8ecd0 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Core" italic aligned box ht (BT.n.y-OS.s.y)+$margin wid In.wid+$margin \\ at Pager fill 0xd0ece8 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Backend" italic aligned box ht (Tokenizer.n.y-CG.s.y)+$margin wid In.wid+$margin \\ at 1/2<Tokenizer.n,CG.s> fill 0xe8d8d0 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "SQL Compiler" italic aligned box ht (UT.n.y-TC.s.y)+$margin wid In.wid+$margin \\ at 1/2<UT,TC> fill 0xe0ecc8 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "Accessories" italic aligned }] set examples(190) [UnguardBs { # pikchr.org file doc/examples.md extract 03 lineht *= 0.4 $margin = lineht*2.5 scale = 0.75 fontscale = 1.1 charht *= 1.15 down In: box "Interface" wid 150% ht 75% fill white arrow CP: box same "SQL Command" "Processor" arrow VM: box same "Virtual Machine" arrow down 1.25*$margin BT: box same "B-Tree" arrow box same "Pager" arrow OS: box same "OS Interface" box same with .w at 1.25*$margin east of 1st box.e "Tokenizer" arrow box same "Parser" arrow CG: box same ht 200% "Code" "Generator" UT: box same as 1st box at (Tokenizer,Pager) "Utilities" move lineht TC: box same "Test Code" arrow from CP to 1/4<Tokenizer.sw,Tokenizer.nw> chop arrow from 1/3<CG.nw,CG.sw> to CP chop box ht (In.n.y-VM.s.y)+$margin wid In.wid+$margin \\ at CP fill 0xd8ecd0 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Core" italic aligned box ht (BT.n.y-OS.s.y)+$margin wid In.wid+$margin \\ at Pager fill 0xd0ece8 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Backend" italic aligned box ht (Tokenizer.n.y-CG.s.y)+$margin wid In.wid+$margin \\ at 1/2<Tokenizer.n,CG.s> fill 0xe8d8d0 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "SQL Compiler" italic aligned box ht (UT.n.y-TC.s.y)+$margin wid In.wid+$margin \\ at 1/2<UT,TC> fill 0xe0ecc8 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "Accessories" italic aligned }] set examples(191) [UnguardBs { # pikchr.org file tests/test56.pikchr lineht *= 0.4 $margin = lineht*2.5 scale = 0.5 fontscale = 1.125 down In: box "Interface" wid 150% ht 75% fill white arrow CP: box same "SQL Command" "Processor" arrow VM: box same "Virtual Machine" arrow down 1.25*$margin BT: box same "B-Tree" arrow box same "Pager" arrow OS: box same "OS Interface" box same with .w at 1.25*$margin east of 1st box.e "Tokenizer" arrow box same "Parser" arrow CG: box same ht 200% "Code" "Generator" UT: box same as 1st box at (Tokenizer,Pager) "Utilities" move lineht TC: box same "Test Code" arrow from CP to 1/4<Tokenizer.sw,Tokenizer.nw> chop arrow from 1/3<CG.nw,CG.sw> to CP chop box ht (In.n.y-VM.s.y)+$margin wid In.wid+$margin \\ at CP fill 0xd8ecd0 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Core" italic aligned box ht (BT.n.y-OS.s.y)+$margin wid In.wid+$margin \\ at Pager fill 0xd0ece8 behind In line invis from 0.25*$margin east of last.sw up last.ht \\ "Backend" italic aligned box ht (Tokenizer.n.y-CG.s.y)+$margin wid In.wid+$margin \\ at 1/2<Tokenizer.n,CG.s> fill 0xe8d8d0 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "SQL Compiler" italic aligned box ht (UT.n.y-TC.s.y)+$margin wid In.wid+$margin \\ at 1/2<UT,TC> fill 0xe0ecc8 behind In line invis from 0.25*$margin west of last.se up last.ht \\ "Accessories" italic aligned }] set examples(192) { # pikchr.org file tests/test57a.pikchr line up 25% "aligned centered above" above aligned } set examples(193) { # pikchr.org file tests/test57b.pikchr line up 25% "aligned ljust above" above aligned ljust } set examples(194) { # pikchr.org file tests/test57c.pikchr line up 25% "aligned rjust below" aligned rjust below } set examples(195) { # pikchr.org file tests/gridlines1.pikchr # Gridlines # (Copied, with modifications, from a post by Steve Nicolai. # thickness *= 0.5 line color gray from -1.25, 1 to 1.25, 1 line same from -1.25, .5 to 1.25, .5 line same from -1.25, -0.5 to 1.25, -0.5 line same from -1.25, -1 to 1.25, -1 line same from -1.0, -1.25 to -1.0, 1.25 line same from -0.5, -1.25 to -0.5, 1.25 line same from 0.5, -1.25 to 0.5, 1.25 line same from 1.0, -1.25 to 1.0, 1.25 right arrow from -1.375, 0 to 1.375, 0 thick text "x" fit up arrow from 0, -1.375 to 0, 1.375 thick text "y" fit } set examples(196) { # pikchr.org file tests/test59.pikchr box "1cm top" "2cm bottom" "3cm right" "4cm left" fit topmargin = 1cm bottommargin = 2cm rightmargin = 3cm leftmargin = 4cm } set examples(197) { # pikchr.org file tests/test64.pikchr # Macro created within another macro define dodef { define $1 {box "Hello"} } dodef(xyz) xyz rightmargin = 2in print "Should just say 'hello'" } set examples(198) { # pikchr.org file tests/test65.pikchr box "autofit" "width" width 0 move box "autofit" "height" height 0 move box "autofit" "both" width 0 height 0 move box "manual" "fit" fit move box "none" move to 1in below first box.w right circle "autofit" "width" width 0 move circle "autofit" "height" height 0 move circle "autofit" "both" width 0 height 0 move circle "manual" "fit" "test" fit move circle "none" move to 1in below first circle.w right ellipse "autofit" "width" width 0 move ellipse "autofit" "height" height 0 move ellipse "autofit" "both" width 0 height 0 move ellipse "a new" "manual fit test" "experiment" fit move ellipse "none" move to 1in below first ellipse.w right cylinder "autofit" "width" width 0 move cylinder "autofit" "height" height 0 move cylinder "autofit" "both" width 0 height 0 move cylinder "manual" "fit" fit move cylinder "none" move to 1in below first cylinder.w right file "autofit" "width" width 0 move file "autofit" "height" height 0 move file "autofit" "both" width 0 height 0 move file "manual" "fit" fit move file "none" move to 1in below first file.w right oval "autofit" "width" width 0 move oval "autofit" "height" height 0 move oval "autofit" "both" width 0 height 0 move oval "manual" "fit" fit move oval "none" move to 1in below first oval.w right diamond "diamond" "autofit" "width" width 0 move 50% diamond "autofit height" height 0 move same diamond "both" width 0 height 0 move same diamond "fit" fit move same diamond "diamond" "wihtout autofit" } set examples(199) { # pikchr.org file tests/test66.pikchr boxwid = -1; boxht = -1; /* Autofit boxes */ box "Testing \\backslash\\ support" "Also \"autofit\"" move box "\a\b\c\f\t\n" } set examples(200) { # pikchr.org file tests/test67.pikchr box invis "invis" move box same solid "same" "solid" move box thin "thin" move box same solid "same" "solid" } set examples(201) { # pikchr.org file tests/test68.pikchr # Nested macros define m00 {box $1 $2 $3 fit;} define m01 {m00("m01",$1,$2);} m01("one","two") } set examples(202) [UnguardBs { # pikchr.org file tests/test69.pikchr # Font size layout tests # box "small*2" small small fit move 10% box "small" small fit move same box "normal" fit move same box "big" big fit move same box "big*2" big big fit move to 2cm below 1st box.w box "very small" small small "small" small "normal" \\ "big" big "very big" big big fit move box "Very big" big big "big" big "normal" \\ "small" small "very small" small small fit }] set examples(203) { # pikchr.org file tests/test70.pikchr fill = bisque B1: box "Pointy" "Diamond" width 150% invis line from B1.w to B1.n to B1.e to B1.s close behind B1 rad 0px move B2: box "Rounded" "Diamond" width 150% invis with .w at 1cm right of B1.e line from B2.w to B2.n to B2.e to B2.s close behind B2 rad 20px dot fill red at 1st line.start dot fill red at last line.start } set examples(204) [UnguardBs { # pikchr.org file tests/test71.pikchr fill = bisque linerad = 15px leftmargin = 2cm oval "SUBMIT TICKET" width 150% down arrow 50% NEW: file "New bug ticket" "marked \"Open\"" fit arrow same box "Triage," "augment &" "correct" fit arrow same DC: box "Developer comments" fit arrow same FR: box "Filer responds" fit arrow 100% REJ: diamond "Reject?" right arrow 100% "Yes" above box "Mark ticket" "\"Rejected\" &" "\"Resolved\"" fit with .w at previous.e arrow right 50% REJF: file "Rejected" "ticket" fit arrow right 50% REOP: diamond "Reopen?" down REJA: arrow 75% from REJ.s " No; fix it" ljust CHNG: box "Developer changes code" with .n at last arrow.s fit arrow 50% FIXD: diamond "Fixed?" right FNO: arrow "No" above RES: box "Optional:" "Update ticket resolution:" "\"Partial Fix\", etc." fit down arrow 75% " Yes" ljust from FIXD.s box "Mark ticket" "\"Fixed\" & \"Closed\"" fit arrow 50% RESF: file "Resolved ticket" fit arrow same oval "END" line from 0.3<FR.ne,FR.se> right even with 0.25 right of DC.e then \\ up even with DC.e then to DC.e -> line from NEW.w left 0.5 then down even with REJ.w then to REJ.w -> line invis from 2nd vertex of last line to 3rd vertex of last line \\ "fast reject path" above aligned line from RES.e right 0.3 then up even with CHNG.e then to CHNG.e -> line from REOP.s "No" aligned above down 0.4 line from previous.s down to (previous.s, RESF.e) then to RESF.e -> line from REOP.n "Yes" aligned below up 0.3 line from previous.n up even with 0.6<FR.ne,FR.se> then to 0.6<FR.ne,FR.se> -> }] set examples(205) { # pikchr.org file tests/test72.pikchr C1: cylinder "radius 0%" rad 0 move cylinder "radius 50%" rad 50% move cylinder "radius 100%" C1B: cylinder "fit 0%" rad 0 fit with .n at 0.5cm below C1.s move cylinder "fit 50%" rad 50% fit move cylinder "fit 100%" fit C2: cylinder "radius 125%" rad 125% with .n at 0.5cm below C1B.s move cylinder "radius 150%" rad 150% move cylinder "radius 200%" rad 200% C3: cylinder "fit 125%" rad 125% with .n at 0.5cm below C2.s fit move cylinder "fit 150%" rad 150% fit move cylinder "fit 200%" rad 200% fit C4: cylinder "fit" "80%" rad 80% with .n at 0.5cm below C3.s fit move cylinder "fit" "120%" rad 120% fit move cylinder "fit" "150%" rad 150% fit } set examples(206) { # pikchr.org file tests/test73.pikchr # Deliberate Error: overflowing text /* Large radius on cylinders ** Forum post 983b36dbcf 2021-01-31 */ C1: cylinder "rad 0%" rad 0 move cylinder "rad 50%" rad 50% move cylinder "rad 100%" C1b: cylinder "rad +1cm" rad +1cm with .n at 0.5cm below C1.s move cylinder "rad -1cm" rad -1cm move cylinder "rad -10px" rad -10px C2: cylinder "fit 0%" rad 0 fit with .n at 1cm below C1b.s move cylinder "fit 200%" rad 200% fit move cylinder "fit 300%" rad 300% fit C3: cylinder "fit 400%" rad 400% fit with .n at 0.5cm below C2.s move cylinder "fit +10px" rad +10px fit move cylinder "fit -10px" rad -10px fit C4: cylinder "fit 1000%" rad 1000% fit with .n at 0.5cm below C3.s move cylinder "fit +1cm" rad +1cm fit move cylinder "fit -1cm" rad -1cm fit } set examples(207) [UnguardBs { # pikchr.org file tests/test74.pikchr /* Use of the "this" objectname */ A: box "a" fit ht this.wid B: box "bbbb" fit ht this.wid with .sw at previous.se C: box "ccccccccc" fit ht this.wid with .sw at previous.se D: box "a" fit ht this.wid rad 0.25*this.wid \\ with .n at 1cm below A.s E: box "bbbb" fit ht this.wid rad 0.25*this.wid \\ with .n at (previous.e.x+0.5*this.width, previous.n.y) F: box "ccccccccc" fit ht this.wid rad 0.25*this.wid \\ with .n at (previous.e.x+0.5*this.wid, previous.n.y) }] set examples(208) { # pikchr.org file tests/test75.pikchr box "Alternative spellings for arrow tokens <-, ->, and <->" invis fit line → "&rarr;" above from (previous.s.x-1.5cm,previous.s.y-0.75cm) right 3cm; line → "&rightarrow;" above from 0.75cm below previous.start right 3cm; line → "→" above from 0.75cm below previous.start right 3cm; line ← "&larr;" above from 0.75cm below previous.start right 3cm; line ← "&leftarrow;" above from 0.75cm below previous.start right 3cm; line ← "←" above from 0.75cm below previous.start right 3cm; line ↔ "&leftrightarrow;" above from 0.75cm below previous.start right 3cm; line ↔ "↔" above from 0.75cm below previous.start right 3cm; } set examples(209) { # pikchr.org file tests/test76.pikchr box "Function test" width 5cm pi = 3.1415926 print "abs(-10):",abs(-10) print "cos(pi/3):",cos(pi/3) print "int(18.5):",int(18.5) print "max(5,-18.23):", max(5,-18.23) print "min(5,-18.23):", min(5,-18.23) print "sin(pi/6):",sin(pi/6) print "sqrt(16):",sqrt(16) } set examples(210) [UnguardBs { # pikchr.org file tests/test77.pikchr arrow right box width 2*boxht "Start" arrow box same "Right" move to 1st box.s down arrow box same "Down" arrow box same "Should continue down" "from \"Down\"" "not to the right!" \\ "See forum post 75a2220c44" "on 2023-08-12" fit }] set examples(211) { # pikchr.org file tests/test78.pikchr down text "Zero Thickness Objects" box "Box" fill lightblue thickness 0 fit circle "Circle" fill yellow thickness 0 fit file "File" fill lightgreen thickness 0 fit oval "Oval 1" fill pink thickness 0 fit oval "Oval 2" fill lightgrey width 1.1cm height 2cm thickness 0 cylinder "Cylinder" fill orange fit thickness 0 diamond "Diamond" fill lightblue fit thickness 0 } set examples(212) { # pikchr.org file tests/test79.pikchr box "Negative" "Thickness" "Lines" fit move arrow "above" above "below" below move arrow "above" above "below" below thickness -0.1 move arrow "above" above "below" below thickness -0.2 } set examples(213) [UnguardBs { # pikchr.org file tests/test80.pikchr TITLE: text "'with .start at' tests..." \\ "Top row should match bottom row" \\ "Forum post a48fbe155b on 2024-06-25" fit B1: box with .nw at 1cm below TITLE.sw C1: circle with .start at B1.end B2: box with .n at 3cm below B1.n C2: circle down B3: box with .w at 1cm right of C1.e C3: circle with .start at B3.end B4: box with .n at 3cm below B3.n C4: circle left B5: box with .n at 4cm right of B3.n C5: circle with .start at B5.end B6: box with .n at 3cm below B5.n C6: circle up B7: box with .n at 2.5cm right of B5.s C7: circle with .start at B7.end B8: box with .n at 3cm below B7.n C7: circle }] set examples(214) [UnguardBs { # pikchr.org file tests/test81.pikchr text "Box B should full sized - not fit-to-text." \\ "See forum post f9f5d90f33 on 2025-03-03." down text "A" box "B" with nw at A.e }] set examples(215) { # textForSvg test file debug-labels.pikchr D1: dot color red arrow go 150% heading 90 "aligned" aligned above arrow go 150% heading 0 "aligned" aligned above from D1 arrow go 150% heading 270 "aligned" aligned above from D1 arrow go 150% heading 180 "aligned" aligned above from D1 move to 4cm east of D1 D2: dot color red arrow go 150% heading 45 "aligned" aligned above from D2 arrow go 150% heading 315 "aligned" aligned above from D2 arrow go 150% heading 225 "aligned" aligned above from D2 arrow go 150% heading 135 "aligned" aligned above from D2 } set examples(216) { # pikchr.org forum post O: text "DREAMS" color grey circle rad 0.9 at 0.6 above O thick color red text "INEXPENSIVE" big bold at 0.9 above O color red circle rad 0.9 at 0.6 heading 120 from O thick color green text "FAST" big bold at 0.9 heading 120 from O color green circle rad 0.9 at 0.6 heading -120 from O thick color blue text "HIGH" big bold "QUALITY" big bold at 0.9 heading -120 from O color blue text "EXPENSIVE" at 0.55 below O color cyan text "SLOW" at 0.55 heading -60 from O color magenta text "POOR" "QUALITY" at 0.55 heading 60 from O color gold } set examples(217) [UnguardBs { # pikchr.org forum post by user pskechr on 2025-06-04 # https://pikchr.org/home/forumpost/33c0c524893390e6 [ [ layer = 2 X: line from (-1.875in+arrowwid,0) to (1.875in-arrowwid,0) thin thin color darkgrey line from arrowwid left of X.start then right arrowwid color darkgrey <- line from X.end then right arrowwid color darkgrey -> text "x" italic with n at X.end color darkgrey Y: line from (0,-1.875in+arrowwid) to (0,1.875in-arrowwid) thin thin color darkgrey line from arrowwid below Y.start then up arrowwid color darkgrey <- line from Y.end then up arrowwid color darkgrey -> text "y " italic with e at Y.end color darkgrey layer = 5 O1: circle with c at (0,0) width 0.05in thin color red fill pink text "O₁" italic with c at 0.16in heading 47 from O1.c color red O2: circle with c at O1.c+(-0.2in,0) width 0.05in thin color blue fill lightblue text "O₂" italic with c at 0.14in heading 160 from O2.c color blue layer = 3 C1: circle with c at O1.c radius 1.625in thin dashed 0.025in color red text "C₁" italic with c at 0.12in heading 60 from C1.radius heading 60 from C1.c color red C2: circle with c at O2.c radius 1.25in thin dashed 0.025in color blue text "C₂" italic with c at 0.1in heading 240 from C2.radius heading 60 from C2.c color blue define drawNewtonTransform { layer = 5 P1: circle same as O1 with c at C1.radius heading $1 from C1.c P2: circle same as O2 with c at C2.radius/dist(C2.c,P1) between C2.c and P1 Q: circle with c at (P1,P2) width 0.05in thin color black fill lightgrey layer = 3 line from C2.c then to P1 then to Q then to P2 thin dashed 0.025in } drawNewtonTransform(23.881) drawNewtonTransform(123.528) layer = 5 text "P₁" italic with c at 0.13in heading 120 from P1.c color red text "P₂" italic with c at 0.17in heading 263 from P2.c color blue text "Q" italic with c at 0.14in heading -30 from Q.c color black drawNewtonTransform(216.119) drawNewtonTransform(296.472) layer = 4 FE: line \\ from (C1.radius heading 5*0 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*0 from C1.c) between C2.c and C1.radius heading 5*0 from C1.c) \\ then to (C1.radius heading 5*1 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*1 from C1.c) between C2.c and C1.radius heading 5*1 from C1.c) \\ then to (C1.radius heading 5*2 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*2 from C1.c) between C2.c and C1.radius heading 5*2 from C1.c) \\ then to (C1.radius heading 5*3 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*3 from C1.c) between C2.c and C1.radius heading 5*3 from C1.c) \\ then to (C1.radius heading 5*4 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*4 from C1.c) between C2.c and C1.radius heading 5*4 from C1.c) \\ then to (C1.radius heading 5*5 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*5 from C1.c) between C2.c and C1.radius heading 5*5 from C1.c) \\ then to (C1.radius heading 5*6 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*6 from C1.c) between C2.c and C1.radius heading 5*6 from C1.c) \\ then to (C1.radius heading 5*7 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*7 from C1.c) between C2.c and C1.radius heading 5*7 from C1.c) \\ then to (C1.radius heading 5*8 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*8 from C1.c) between C2.c and C1.radius heading 5*8 from C1.c) \\ then to (C1.radius heading 5*9 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*9 from C1.c) between C2.c and C1.radius heading 5*9 from C1.c) \\ then to (C1.radius heading 5*10 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*10 from C1.c) between C2.c and C1.radius heading 5*10 from C1.c) \\ then to (C1.radius heading 5*11 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*11 from C1.c) between C2.c and C1.radius heading 5*11 from C1.c) \\ then to (C1.radius heading 5*12 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*12 from C1.c) between C2.c and C1.radius heading 5*12 from C1.c) \\ then to (C1.radius heading 5*13 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*13 from C1.c) between C2.c and C1.radius heading 5*13 from C1.c) \\ then to (C1.radius heading 5*14 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*14 from C1.c) between C2.c and C1.radius heading 5*14 from C1.c) \\ then to (C1.radius heading 5*15 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*15 from C1.c) between C2.c and C1.radius heading 5*15 from C1.c) \\ then to (C1.radius heading 5*16 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*16 from C1.c) between C2.c and C1.radius heading 5*16 from C1.c) \\ then to (C1.radius heading 5*17 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*17 from C1.c) between C2.c and C1.radius heading 5*17 from C1.c) \\ then to (C1.radius heading 5*18 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*18 from C1.c) between C2.c and C1.radius heading 5*18 from C1.c) \\ then to (C1.radius heading 5*19 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*19 from C1.c) between C2.c and C1.radius heading 5*19 from C1.c) \\ then to (C1.radius heading 5*20 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*20 from C1.c) between C2.c and C1.radius heading 5*20 from C1.c) \\ then to (C1.radius heading 5*21 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*21 from C1.c) between C2.c and C1.radius heading 5*21 from C1.c) \\ then to (C1.radius heading 5*22 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*22 from C1.c) between C2.c and C1.radius heading 5*22 from C1.c) \\ then to (C1.radius heading 5*23 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*23 from C1.c) between C2.c and C1.radius heading 5*23 from C1.c) \\ then to (C1.radius heading 5*24 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*24 from C1.c) between C2.c and C1.radius heading 5*24 from C1.c) \\ then to (C1.radius heading 5*25 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*25 from C1.c) between C2.c and C1.radius heading 5*25 from C1.c) \\ then to (C1.radius heading 5*26 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*26 from C1.c) between C2.c and C1.radius heading 5*26 from C1.c) \\ then to (C1.radius heading 5*27 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*27 from C1.c) between C2.c and C1.radius heading 5*27 from C1.c) \\ then to (C1.radius heading 5*28 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*28 from C1.c) between C2.c and C1.radius heading 5*28 from C1.c) \\ then to (C1.radius heading 5*29 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*29 from C1.c) between C2.c and C1.radius heading 5*29 from C1.c) \\ then to (C1.radius heading 5*30 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*30 from C1.c) between C2.c and C1.radius heading 5*30 from C1.c) \\ then to (C1.radius heading 5*31 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*31 from C1.c) between C2.c and C1.radius heading 5*31 from C1.c) \\ then to (C1.radius heading 5*32 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*32 from C1.c) between C2.c and C1.radius heading 5*32 from C1.c) \\ then to (C1.radius heading 5*33 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*33 from C1.c) between C2.c and C1.radius heading 5*33 from C1.c) \\ then to (C1.radius heading 5*34 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*34 from C1.c) between C2.c and C1.radius heading 5*34 from C1.c) \\ then to (C1.radius heading 5*35 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*35 from C1.c) between C2.c and C1.radius heading 5*35 from C1.c) \\ then to (C1.radius heading 5*36 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*36 from C1.c) between C2.c and C1.radius heading 5*36 from C1.c) \\ then to (C1.radius heading 5*37 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*37 from C1.c) between C2.c and C1.radius heading 5*37 from C1.c) \\ then to (C1.radius heading 5*38 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*38 from C1.c) between C2.c and C1.radius heading 5*38 from C1.c) \\ then to (C1.radius heading 5*39 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*39 from C1.c) between C2.c and C1.radius heading 5*39 from C1.c) \\ then to (C1.radius heading 5*40 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*40 from C1.c) between C2.c and C1.radius heading 5*40 from C1.c) \\ then to (C1.radius heading 5*41 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*41 from C1.c) between C2.c and C1.radius heading 5*41 from C1.c) \\ then to (C1.radius heading 5*42 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*42 from C1.c) between C2.c and C1.radius heading 5*42 from C1.c) \\ then to (C1.radius heading 5*43 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*43 from C1.c) between C2.c and C1.radius heading 5*43 from C1.c) \\ then to (C1.radius heading 5*44 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*44 from C1.c) between C2.c and C1.radius heading 5*44 from C1.c) \\ then to (C1.radius heading 5*45 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*45 from C1.c) between C2.c and C1.radius heading 5*45 from C1.c) \\ then to (C1.radius heading 5*46 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*46 from C1.c) between C2.c and C1.radius heading 5*46 from C1.c) \\ then to (C1.radius heading 5*47 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*47 from C1.c) between C2.c and C1.radius heading 5*47 from C1.c) \\ then to (C1.radius heading 5*48 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*48 from C1.c) between C2.c and C1.radius heading 5*48 from C1.c) \\ then to (C1.radius heading 5*49 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*49 from C1.c) between C2.c and C1.radius heading 5*49 from C1.c) \\ then to (C1.radius heading 5*50 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*50 from C1.c) between C2.c and C1.radius heading 5*50 from C1.c) \\ then to (C1.radius heading 5*51 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*51 from C1.c) between C2.c and C1.radius heading 5*51 from C1.c) \\ then to (C1.radius heading 5*52 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*52 from C1.c) between C2.c and C1.radius heading 5*52 from C1.c) \\ then to (C1.radius heading 5*53 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*53 from C1.c) between C2.c and C1.radius heading 5*53 from C1.c) \\ then to (C1.radius heading 5*54 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*54 from C1.c) between C2.c and C1.radius heading 5*54 from C1.c) \\ then to (C1.radius heading 5*55 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*55 from C1.c) between C2.c and C1.radius heading 5*55 from C1.c) \\ then to (C1.radius heading 5*56 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*56 from C1.c) between C2.c and C1.radius heading 5*56 from C1.c) \\ then to (C1.radius heading 5*57 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*57 from C1.c) between C2.c and C1.radius heading 5*57 from C1.c) \\ then to (C1.radius heading 5*58 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*58 from C1.c) between C2.c and C1.radius heading 5*58 from C1.c) \\ then to (C1.radius heading 5*59 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*59 from C1.c) between C2.c and C1.radius heading 5*59 from C1.c) \\ then to (C1.radius heading 5*60 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*60 from C1.c) between C2.c and C1.radius heading 5*60 from C1.c) \\ then to (C1.radius heading 5*61 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*61 from C1.c) between C2.c and C1.radius heading 5*61 from C1.c) \\ then to (C1.radius heading 5*62 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*62 from C1.c) between C2.c and C1.radius heading 5*62 from C1.c) \\ then to (C1.radius heading 5*63 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*63 from C1.c) between C2.c and C1.radius heading 5*63 from C1.c) \\ then to (C1.radius heading 5*64 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*64 from C1.c) between C2.c and C1.radius heading 5*64 from C1.c) \\ then to (C1.radius heading 5*65 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*65 from C1.c) between C2.c and C1.radius heading 5*65 from C1.c) \\ then to (C1.radius heading 5*66 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*66 from C1.c) between C2.c and C1.radius heading 5*66 from C1.c) \\ then to (C1.radius heading 5*67 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*67 from C1.c) between C2.c and C1.radius heading 5*67 from C1.c) \\ then to (C1.radius heading 5*68 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*68 from C1.c) between C2.c and C1.radius heading 5*68 from C1.c) \\ then to (C1.radius heading 5*69 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*69 from C1.c) between C2.c and C1.radius heading 5*69 from C1.c) \\ then to (C1.radius heading 5*70 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*70 from C1.c) between C2.c and C1.radius heading 5*70 from C1.c) \\ then to (C1.radius heading 5*71 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*71 from C1.c) between C2.c and C1.radius heading 5*71 from C1.c) \\ then to (C1.radius heading 5*72 from C1.c, C2.radius/dist(C2.c,C1.radius heading 5*72 from C1.c) between C2.c and C1.radius heading 5*72 from C1.c) \\ close color black fill none line from FE.start same as FE color none fill whitesmoke behind X text "Fₑ" italic with c at 0.11 heading 190 from (C1.radius heading 45 from C1.c, C2.radius/dist(C2.c,C1.radius heading 45 from C1.c) between C2.c and C1.radius heading 45 from C1.c) ] [ A: box width 0.1875in height 0.2in "O₁" italic rjust thin thin invisible color red B: box width 2.14in height 0.2in " = Center of 1ˢᵗ circle" ljust with w at 0.04in left of previous.e thin thin invisible color red box same as A "C₁" italic rjust with ne at 0.04in above 2nd previous box .se color red box same as B " = Circumference of 1ˢᵗ circle" ljust with w at 0.04in left of previous.e color red box same as A "P₁" italic rjust with ne at 0.04in above 2nd previous box .se color red box same as B " = Point on C₁" ljust with w at 0.04in left of previous.e color red box same as A "O₂" italic rjust with ne at 0.04in above 2nd previous box .se color blue box same as B " = Center of 2ⁿᵈ circle" ljust with w at 0.04in left of previous.e color blue box same as A "C₂" italic rjust with ne at 0.04in above 2nd previous box .se color blue box same as B " = Circumference of 2ⁿᵈ circle" ljust with w at 0.04in left of previous.e color blue box same as A "P₂" italic rjust with ne at 0.04in above 2nd previous box .se color blue box same as B " = Point at intersection of line O₂P₁ and C₂" ljust with w at 0.04in left of previous.e color blue box same as A "Q " italic rjust with ne at 0.04in above 2nd previous box .se color black box same as B " = Point at (P₁.x, P₂.y)" ljust with w at 0.04in left of previous.e color black box same as A "Fₑ" italic rjust with ne at 0.04in above 2nd previous box .se color black box same as B " = All Q for all P₁, P₂" ljust with w at 0.04in left of previous.e color black ] with nw at previous.ne+(0.375in,-0.125in) box with c at previous.c width previous.width+0.0625in height previous.height+0.0625in thin thin color darkgrey ] text "Hügelschäffer egg curve" with n at 0.0625in below previous.s }] set examples(218) { # pikchr.org forum post by user notlibrary on 2023-09-04 # https://pikchr.org/home/forumpost/14b4cd4c04ea1daf #"Quiver" macro example by @notlibrary define quiver { dot invis at 0.5 < $1.ne , $1.e > dot invis at 0.5 < $1.nw , $1.w > dot invis at 0.5 < $1.se , $1.e > dot invis at 0.5 < $1.sw , $1.w > dot at $2 right of 4th previous dot dot at $3 right of 4th previous dot dot at $4 right of 4th previous dot dot at $5 right of 4th previous dot arrow <- from previous dot to 2nd previous dot arrow -> from 3rd previous dot to 4th previous dot } define show_compass_l { dot color red at $1.e " .e" ljust dot same at $1.ne " .ne" ljust above line thick color green from previous to 2nd last dot } define show_compass_r { dot color red at $1.w " .w" ljust dot same at $1.nw " .nw" ljust above line thick color green from previous to 2nd last dot } PROGRAM: file "Program" rad 45px show_compass_l(PROGRAM) QUIVER: box invis ht 0.75 DATABASE: oval "Database" ht 0.75 wid 1.1 show_compass_r(DATABASE) quiver(QUIVER, 5px, -5px, 5px, 0px) text "Query" with .c at 0.1in above last arrow text "Records" with .c at 0.1in below 2nd last arrow } set examples(219) [UnguardBs { # pikchr.org forum post by Mike Swanson (user chungy) on 2025-04-23 # With revisions by Zellyn Hunter (user zellyn) # https://pikchr.org/home/forumpost/71d6ebf831 # No text! A honeycomb design. define $hex { line from previous.e go 0.25cm heading 0 \\ then 0.5cm heading 60 \\ then 0.5cm heading 120 \\ then 0.5cm heading 180 \\ then 0.5cm heading 240 \\ then 0.5cm heading 300 \\ then 0.25cm heading 0 color gold close fill goldenrod } define $new_longer_row { line from $1.w go 0.25cm heading 180 invis $2: line from previous.s go 0.5cm heading 240 \\ then 0.5cm heading 180 \\ then 0.5cm heading 120 \\ then 0.5cm heading 60 \\ then 0.5cm heading 0 color gold close fill goldenrod } define $new_shorter_row { $2: line from $1.s go 0.5cm heading 180 \\ then 0.5cm heading 120 \\ then 0.5cm heading 60 \\ then 0.5cm heading 0 \\ then 0.5cm heading 300 color gold close fill goldenrod } H0: dot invis $new_shorter_row(H0, H1); $hex(); $hex(); $hex(); $new_longer_row(H1, H2); $hex(); $hex(); $hex(); $hex(); $new_longer_row(H2, H3); $hex(); $hex(); $hex(); $hex(); $hex(); $new_longer_row(H3, H4); $hex(); $hex(); $hex(); $hex(); $hex(); $hex(); $new_shorter_row(H4, H5); $hex(); $hex(); $hex(); $hex(); $hex(); $new_shorter_row(H5, H6); $hex(); $hex(); $hex(); $hex(); $new_shorter_row(H6, H7); $hex(); $hex(); $hex(); }] set examples(220) [UnguardBs { # pikchr.org forum post by user anonymous on 2025-05-01 # With revisions by Zellyn Hunter (user zellyn) # https://pikchr.org/home/forumpost/1e49ae8b3e # No text! The (new) Minnesota flag. @NightSkyBlue = 0x002D5D @WaterBlue = 0x52C9E8 @White = 0xFFFFFF @N = 1.875in A: box \\ with nw at (0,0) \\ width 5/3*@N \\ height @N \\ color @NightSkyBlue fill @NightSkyBlue thin thin B: line \\ from A.nw+(14/15*@N,0) \\ then to A.ne \\ then to A.se \\ then left until even with A.nw+(14/15*@N,0) \\ then up 1/2*@N left (14/15-13/20)*@N \\ close \\ color @WaterBlue fill @WaterBlue thin thin C: A.nw+(21/60*@N,-1/2*@N) C: line \\ from 11/30/2*@N heading 0*360/8 from C \\ then to 11/30/2*@N heading 3*360/8 from C \\ then to 11/30/2*@N heading 6*360/8 from C \\ then to 11/30/2*@N heading 1*360/8 from C \\ then to 11/30/2*@N heading 4*360/8 from C \\ then to 11/30/2*@N heading 7*360/8 from C \\ then to 11/30/2*@N heading 2*360/8 from C \\ then to 11/30/2*@N heading 5*360/8 from C \\ close \\ color @White fill @White thin thin }] #indent+4 if {[array size examples] != $totalExamples} { ReportError "Expected $totalExamples examples; have [array size examples]." } return } proc GuardBs {in} { set map [list \\\n \\\\\n] string map $map $in } proc UnguardBs {in} { set map [list \\\\\n \\\n] string map $map $in } mainScript |
Added modules/textForSvg/pkgIndex.tcl.
> > | 1 2 | if {![package vsatisfies [package provide Tcl] 8.6-]} {return} package ifneeded textForSvg 1.0b1 [list source [file join $dir textForSvg.tcl]] |
Added modules/textForSvg/textForSvg.man.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | [comment {-*- tcl -*- textForSvg manpage}] [manpage_begin textForSvg n 1.0] [moddesc {Implement Text Elements For Some SVG Images}] [titledesc {Implement Text Elements For Some SVG Images}] [require Tcl 8.6-] [require Tk 8.6-] [require htmlparse] [require img::window] [require tdom 0.9-] [require tksvg 0.14-] [require textForSvg [opt 1.0]] [description] In [package Tk] 8.6 and above, the command [cmd {image create photo}] can create a [package Tk] image from data in SVG format, but it does not render SVG text elements. [para] Command [cmd textForSvg::addText] extracts the text elements from the SVG data, and renders them as text items on a canvas. Module [package textForSvg] is not a complete implementation of SVG text elements, but aims to render a [sectref {Subset of SVG} {large enough subset}] to be useful in drawing the SVG emitted by diagramming tools such as [cmd pikchr], which is available from [uri https://pikchr.org/]. [para] Command [cmd textForSvg::imageCreatePhoto] generates a pure [package Tk] PNG image rather than a canvas widget. [para] Package [package textForSvg]'s functions and variables are contained entirely in the [var ::textForSvg] namespace. [comment {use emph instead of term, because term creates a hyperlink, and [emph canvas] occurs in almost every sentence: the page would be covered with the same hyperlinks many times}] [para] The compatibility package [package tksvg] is needed only for [package Tk] 8.6. Package [package img::window] (part of package [package Img]) is needed only for command [cmd textForSvg::imageCreatePhoto]. [para] If the values for the default font family and its height are unsuitable, they can be changed by the commands [cmd textForSvg::setDefaultFontFamily] and [cmd textForSvg::setDefaultFontHeightInPixels] respectively. The corresponding commands for monospace fonts are [cmd textForSvg::setMonospaceFontFamily] and [cmd textForSvg::setMonospaceFontHeightInPixels] respectively. [section COMMANDS] [subsection {Principal Commands}] [list_begin definitions] [call [cmd textForSvg::addText] [arg xmlData] [arg canv] [opt "[arg imX] [arg imY] [arg binary]"]] Command to render the text elements of a SVG image as text items on a canvas. Before this command is called, typically the [cmd {image create photo}] command has been used to render the SVG image without text, and the image has been added to the canvas as an image item. [list_begin arguments] [arg_def {} xmlData] String containing the SVG data for an image. This may be either a Tcl binary string with UTF-8 encoding (the default) or an ordinary Tcl string. In the latter case, the optional argument [arg binary] must be set to boolean false. [arg_def {} canv] [package Tk] window path for an existing canvas. [arg_def {} imX] The canvas x-coordinate of the top-left corner of the SVG image item. [arg_def {} imY] The canvas y-coordinate of the top-left corner of the SVG image item. [arg_def {} binary] (boolean) true if argument [arg xmlData] is a Tcl binary string with UTF-8 encoding (the default). False if [arg xmlData] is a standard Tcl string. [list_end] [call [cmd textForSvg::imageCreatePhoto] [opt [arg name]] [opt "[arg option] [arg value]..."]] Command to create a [package Tk] photo image in PNG raster format (or a data string that represents this image) from a SVG image specified by option [option -data] or option [option -file]. [para] Use this command if you need a pure image, or its string representation, rather than a [package Tk] canvas with multiple items, which would be the result of calling [cmd textForSvg::addText]. [para] The return value is the name of the image or, if the argument [arg name] is "--", the rasterized PNG image as a binary data string. [para] The command is a substitute for [cmd {image create photo}] that takes SVG image data and creates a complete [package Tk] photo image including any SVG text elements. The command draws a transient canvas window on the screen and uses [package img::window] to convert it to a raster image. It replaces transparent pixels with a background color specified by option [option -transcolor]. [para] NOTE: The command is a [emph substitute] for [cmd {image create photo}] but not an [emph equivalent]. Image instance commands such as [emph name] [cmd {configure|read|write}] relate to the generated PNG image and not to the SVG source data. [para] If the default duration of the transient display is too brief for the canvas to be copied to a PNG image, the PNG may be incomplete or may be plain black or white. If so, the duration can be changed by the command [cmd textForSvg::setCreateDelay]. [list_begin arguments] [arg_def {} name] If specified and not "--", is the name used for the image.[para] If not specified, [package Tk] assigns the image name.[para] If specified as "--", a [package Tk] image is not created, and the return value is the PNG image data as a binary string, not an image name.[para] [list_end] [list_begin options] [opt_def -binary value] [emph (optional)] boolean value. If the value of [option -binary] is true (the default) then any value supplied to [option -data] must be a binary string encoded as UTF-8. This allows drop-in replacement for the [package Tk] command [cmd {image create photo}] which requires binary data. If the value of [option -binary] is false, then any value supplied to [option -data] must be a Tcl string. Option [option -binary] does not apply to images read using option [option -file]. The binary string differs from the Tcl string if non-ASCII characters are included, for example in the SVG text elements. (The option is defined for this command only - it has no counterpart in [cmd {image create photo}].) [opt_def -data value] Specifies the contents of the SVG image as a string holding SVG data. The value can be either a binary string encoded as UTF-8 (the default), or a standard Tcl string: in the latter case, option [option -binary] must be set to boolean false. [para] Either option [option -data] or option [option -file] must be specified. If both options are specified, the [option -file] option is used. (Cf. [cmd {image create photo}] option [option -data]) [opt_def -format value] [emph (optional)] Ignored. (Cf. [cmd {image create photo}] option [option -format]) [opt_def -file value] The name of an image file to read. The file format must be SVG. (Cf. [cmd {image create photo}] option [option -file]) [opt_def -gamma value] [emph (optional)] Ignored. (Cf. [cmd {image create photo}] option [option -gamma]) [opt_def -height value] [emph (optional)] Specifies the height of the image, in pixels. This option is useful primarily in situations where the user wishes to build up the contents of the image piece by piece. A value of "0" (the default) allows the image to expand or shrink vertically to fit the data stored in it. (Cf. [cmd {image create photo}] option [option -height]) [opt_def -metadata value] [emph (optional)] Ignored. (Cf. [cmd {image create photo}] option [option -metadata]) [opt_def -palette value] [emph (optional)] Ignored. (Cf. [cmd {image create photo}] option [option -palette]) [opt_def -scale value] [emph (optional)] scale factor, a positive number. Default value is "1.0". (The option is defined for this command only - it has no counterpart in [cmd {image create photo}].) [opt_def -toplev value] [emph (optional)] [package Tk] window path of the transient toplevel that will be created for the operation. Must not already exist. The toplevel name must begin with a lower-case letter. (The option is defined for this command only - it has no counterpart in [cmd {image create photo}].) [opt_def -transcolor value] [emph (optional)] background color to be shown where the image is transparent. Default value is "#ffffff". Transparency is not preserved. (The option is defined for this command only - it has no counterpart in [cmd {image create photo}].) [opt_def -width value] [emph (optional)] Specifies the width of the image, in pixels. This option is useful primarily in situations where the user wishes to build up the contents of the image piece by piece. A value of "0" (the default) allows the image to expand or shrink vertically to fit the data stored in it. (Cf. [cmd {image create photo}] option [option -width]) [list_end] [list_end] [subsection {Configuration Commands}] [list_begin definitions] [call [cmd textForSvg::cget] [arg option]] Returns the current value of the configuration option given by [arg option]. [arg Option] may have any of the values accepted by the [cmd textForSvg::configure] command. [call [cmd textForSvg::configure] [opt "[arg option] [opt "[arg value] [opt "[arg option] [arg value] ..."]"]"] ] Query or modify the configuration options of the module. If no [arg option] is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If [arg option] is specified with no [arg value], then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no [arg option] is specified). If one or more [arg option]-[arg value] pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. [arg Option] may have any of the values listed below. [list_begin options] [opt_def -delay] The time interval in ms used by command [cmd textForSvg::imageCreatePhoto] between mapping of the SVG image and reading it back as a PNG raster image. When [package textForSvg] is loaded, the initial value is "100". [opt_def -defaultfont] The font family used for non-monospace SVG text elements. The initial value when [package textForSvg] is loaded is the first font family found from the list Arial, Liberation Sans, Nimbus Sans, FreeSans, Droid Sans; if none is found, the font family used by [cmd TkDefaultFont] is chosen. [opt_def -defaultheight] The height in pixels of the font used for non-monospace SVG text elements. A positive integer or floating-point number. The initial value when [package textForSvg] is loaded is "16". This value is suitable for the font family "Arial". For other font families, a slightly different value may be more suitable. [opt_def -monofont] The font family used for monospace SVG text elements. The initial value when [package textForSvg] is loaded is the first font family found from the list Andale Mono, DejaVu Sans Mono, Source Code Pro, Liberation Mono, Nimbus Mono PS, FreeMono; if none is found, the font family that Tk represents with the symbolic name "Courier" is used. [opt_def -monoheight] The height in pixels of the font used for monospace SVG text elements. A positive integer or floating-point number. The initial value when [package textForSvg] is loaded is "13". This value is suitable for the font family "Andale Mono". For other font families, a slightly different value may be more suitable. [list_end] [list_end] [subsection {Auxiliary Commands}] [list_begin definitions] [call [cmd textForSvg::chooseFontFamily] [arg fontList] [arg fallback]] Returns the name of a font family. Selects the first font family from the list [arg fontList] that is available to [package Tk]. If none of the fonts in [arg fontList] is available, the command returns the font family that corresponds to the argument [arg fallback]. [list_begin arguments] [arg_def {} fontList] A list of font families, in order of preference. [arg_def {} fallback] Description of a font that is guaranteed to exist: either one of the [package Tk] standard named fonts (TkDefaultFont, TkTextFont, TkFixedFont, TkMenuFont, TkHeadingFont, TkCaptionFont, TkSmallCaptionFont, TkIconFont, or TkTooltipFont), or one of the placeholder family names used by [package Tk] (Courier, Times, or Helvetica). If the command uses argument [arg fallback] it returns the actual font family to which [arg fallback] corresponds. [list_end] [call [cmd textForSvg::strictConvertFrom] [arg binString] [arg encoding]] A wrapper for command [cmd {encoding convertfrom}]. Converts a binary string that has a particular character encoding to a Tcl string. The command handles conversion errors strictly, whether running on Tcl 8 or Tcl 9. A conversion error causes the command to return with error status. [para] The command is used in [package textForSvg] with [arg encoding] utf-8. [list_begin arguments] [arg_def {} binString] A binary string with character encoding given by argument [arg encoding]. [arg_def {} encoding] A valid character encoding. [list_end] [call [cmd textForSvg::strictConvertTo] [arg tclString] [arg encoding]] A wrapper for command [cmd {encoding convertto}]. Converts a Tcl string to a binary string that has a particular character encoding. The command handles conversion errors strictly, whether running on Tcl 8 or Tcl 9. A conversion error causes the command to return with error status. [para] The command is used in [package textForSvg] with [arg encoding] utf-8. [list_begin arguments] [arg_def {} tclString] A Tcl string. [arg_def {} encoding] A valid character encoding. [list_end] [call [cmd textForSvg::fontIsPresent] [arg family]] Returns a boolean value, true if and only if the font family [arg family] is available to [package Tk]. [list_begin arguments] [arg_def {} family] The name of a font family, e.g. Arial, Times New Roman, Liberation Sans. [list_end] [call [cmd textForSvg::getDefaultFontFamily] [arg style]] Command to return the font family chosen by package [package textForSvg] as the default for style [arg style]. [list_begin arguments] [arg_def {} style] The style of font whose default font family is requested: one of Sans, Serif, or Mono. [list_end] [call [cmd textForSvg::scaleSvg] [arg xmlData] [arg fac]] Command to scale the SVG image held in a data string. This is a pure text-processing command that does not use [package Tk]. The command returns a string containing the scaled SVG image data. [list_begin arguments] [arg_def {} xmlData] String containing the SVG data for an image. [arg_def {} fac] The required scale factor, a positive number. [list_end] [list_end] [section {Subset of SVG}] The specification for Scalable Vector Graphics (SVG) is comprehensive, and this includes its tags for describing text. [package textForSvg] implements only the small subset that is used in the SVG images emitted by [package pikchr]. Other features may be added as needed for [package pikchr] and other diagramming tools. [package textForSvg] is not intended to grow into a full implementation of SVG text rendering. [para] In addition to the contents of each [package <text>] node, [package textForSvg] reads and uses only the following SVG tags and attributes: [list_begin itemized] [item] [package <svg>] attributes [emph height], [emph width] (numbers only, no units or %) [item] [package <svg>] attribute [emph viewBox] [item] [package <text>] attributes [emph text-anchor], [emph font-style] [item] [package <text>] attributes [emph x], [emph y] (numbers only, no units or %) [item] [package <text>] attribute [emph transform] (rotations only) [item] [package <text>] attribute [emph font-size] (% values only) [item] [package <text>] attribute [emph font-family] (if present, value "monospace" only) [item] [package <text>] attribute [emph font-weight] (mapping "bolder" to "bold", "lighter" to "normal", and ignoring numerical values) [item] [package <text>] attribute [emph fill] (24-bit RGB color values only) [list_end] [para] [package textForSvg] does not read [package <tspan>] or [package <textPath>] tags. [section BUGS] This version of [package textForSvg] is intended to be compatible with all releases of [package Tk] 8.6 and above, and with the corresponding development branches in the source code repository for [package Tk]. Any incompatibility with any of these versions, for any [package Tk] windowing system, should be reported as a bug. Please report such in the category [package textForSvg] of the [uri https://core.tcl-lang.org/tklib/reportlist {Tklib Trackers}]. [section EXAMPLE] To map a SVG image held in binary string [emph xmlData]: [example { package require textForSvg canvas .c -bg white image create photo img1 -data $xmlData .c create image 0.0 0.0 -image img1 -anchor nw textForSvg::addText $xmlData .c pack .c }] To create a raster image [emph img2] from a SVG image held in binary string [emph xmlData], and use it in a label .lab: [example { package require textForSvg package require img::window textForSvg::imageCreatePhoto img2 -data $xmlData label .lab -image img2 pack .lab }] A demonstration script in the [emph examples/textForSvg] directory has several images drawn from SVG data generated by [package pikchr]. The [package textForSvg] commands successfully draw all examples (without modification or omission) from the documentation for [package pikchr]. [see_also canvas image photo] [keywords canvas image photo png svg] [manpage_end] |
Added modules/textForSvg/textForSvg.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | # ------------------------------------------------------------------------------ # FILE: # textForSvg-VERSION.tm, textForSvg.tcl # # DESCRIPTION: # Module/Package to add text strings to a SVG image on a canvas. # # LICENCE: # Copyright (C) 2021-2025 Keith Nash. # This file may be used subject to the terms in the Tklib license; # please note in particular the terms repeated here: # # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR # MODIFICATIONS. # # ------------------------------------------------------------------------------ package require Tk 8.6- package require tdom package require htmlparse # package img::window is loaded on demand by imageCreatePhoto. if { ([package vcompare 8.7a0 [package require Tk]] == 1) && (![interp issafe]) } { package require tksvg } elseif {([package vcompare 8.7a0 [package require Tk]] == 1)} { return -code error {unpatched tksvg is not available to safe interpreters\ in Tk 8.6. Consider upgrading to Tcl/Tk 9.0.} } namespace eval textForSvg { variable CONFIG variable FontStyles variable Waiter namespace export addText scaleSvg imageCreatePhoto cget configure namespace export chooseFontFamily strictConvertTo strictConvertFrom fontIsPresent namespace export getDefaultFontFamily } # ------------------------------------------------------------------------------ # Proc textForSvg::addText # ------------------------------------------------------------------------------ # Command to render the text elements of an SVG image as canvas items. # # Notes. # - Argument xmldata is a binary string (utf-8 encoded) by default; but if a Tcl # string is available it can be used by setting argument "binary" to 0. # - The binary format is needed by the command "image create photo -data", and # is the default for command textForSvg::imageCreatePhoto. # # Arguments: # xmldata - a string holding SVG image data # can - the canvas to which text strings will be added as canvas items # imX - (optional, integer) horizontal offset of text items in canvas # i.e. The canvas x-coordinate of the top-left corner of the SVG # image item in canvas pixel coordinates (a floating point number) # imY - (optional, integer) vertical offset of text items in canvas # i.e. The canvas y-coordinate of the top-left corner of the SVG # image item in canvas pixel coordinates (a floating point number) # binary - (optional, boolean) iff true, argument xmldata is provided as a # binary string with utf-8 encoding. Otherwise as a Tcl string. # # Return Value: list of canvas item ids for text items created by the command # ------------------------------------------------------------------------------ proc textForSvg::addText {xmldata can {imX 0} {imY 0} {binary 1}} { if {!$binary} { set xmldataTcl $xmldata } elseif {[catch {strictConvertFrom $xmldata utf-8} res]} { set msg {argument "binary" is true, requesting conversion of\ argument "xmldata" from a utf-8-encoded binary string\ to a Tcl string; but this conversion failed} append msg " - $res" return -code error $msg } else { # Argument $xmldata is a binary string whose bytes are valid UTF-8. # xmldataTcl is the corresponding Tcl string. set xmldataTcl $res } if {![string match -nocase *<svg* $xmldataTcl]} { # Not valid SVG. Nothing to do. return } set lwc [string tolower $xmldataTcl] set pos1 [string first <svg $lwc] set pos2 [string last </svg> $lwc] if {$pos1 == -1 || $pos2 == -1 || ($pos2 < $pos1)} { # Not valid SVG. Nothing to do. return } # printing is valid even if pos1 is 0. # Currently unused. # FIXME display it; also error messages from pikchr/tDOM. set printing [string range $xmldataTcl 0 $pos1-1] set printing2 [string range $xmldataTcl $pos2+6 end] set xmldataTcl [string range $xmldataTcl $pos1 $pos2+5] # tDOM crashes if it finds inessential character entities. # So, escape the essential 5 again; then unescape the lot in one call. set map [list {<} {&lt;} {>} {&gt;} \ {&} {&amp;} {'} {&apos;} \ {"} {&quot;}] set xmldataTcl [string map $map $xmldataTcl] set xmldataTcl [htmlparse::mapEscapes $xmldataTcl] if {[catch {dom parse $xmldataTcl} doc]} { # Not valid XML. Nothing to do. # FIXME report error return } lassign [GetScaleFactors $doc] sX sY set txtList [$doc getElementsByTagName text] set SvgTextItems {} foreach xmlNode $txtList { # Copy all attributes of the text node to dictionary attrDict. set attrList [$xmlNode attributes] set attrDict {} foreach attr $attrList { dict set attrDict $attr [$xmlNode getAttribute $attr] } # Skip this node if any of these attributes are missing. foreach attr {x y} { if {$attr ni $attrList} { continue } } # All attributes used below: # x # y # text-anchor # transform # font-family (if present, ="monospace") # font-size # font-style # font-weight # fill # Present but unused: dominant-baseline="central" # Text String. set textString [$xmlNode text] # Text Anchor. set where { start w middle center end e } set anchor [DictGetSafely $where [DictGetSafely $attrDict text-anchor] center] # Text Position. set xAttr [dict get $attrDict x] set yAttr [dict get $attrDict y] lassign [GetRotation [DictGetSafely $attrDict transform]] angle oX oY if {abs($angle) < 1.E-5} { # No rotation. set xRef $xAttr set yRef $yAttr } else { # The rotation is anticlockwise by $angle degrees about (oX, oY). # The canvas item -angle rotates the text, but the anchor of the # item is moved too. set theta [expr {$angle * atan(1.0) / 45.}] set xDel [expr {$xAttr - $oX}] set yDel [expr {$yAttr - $oY}] set xRef [expr {$oX + cos($theta) * $xDel + sin($theta) * $yDel}] set yRef [expr {$oY - sin($theta) * $xDel + cos($theta) * $yDel}] } # Font Size as %. set fontSize [DictGetSafely $attrDict font-size 100%] if { ([string index $fontSize end] eq {%}) && ([string is double -strict [set siz [string range $fontSize 0 end-1]]]) } { # OK } else { set siz 100 } # Font Style. set styles { normal {} italic italic oblique italic } set fontStyle [DictGetSafely $styles [DictGetSafely $attrDict font-style]] # Font Weight. # Numerical values are ignored. # Values "bolder", "lighter" are supposed to be relative to parent element. set weights { normal {} bold bold bolder bold lighter {} } set fontWeight [DictGetSafely $weights [DictGetSafely $attrDict font-weight]] # Font Color. set color [GetColor [DictGetSafely $attrDict fill]] # Font Family. Default (attribute not present) or "monospace". if {[DictGetSafely $attrDict font-family] eq {monospace}} { set fam [cget -monofont] set fht [cget -monoheight] } else { set fam [cget -defaultfont] set fht [cget -defaultheight] } # Font Definition: family, size, style, and weight. # Cannot change the font aspect ratio, so scale the font size by # the horizontal scale factor. set fontPix [expr {round(-1 * $fht * $sX * $siz / 100.)}] set font [list $fam $fontPix {*}$fontStyle {*}$fontWeight] # Define the canvas item of type "text", and record its index. lappend SvgTextItems [$can create text \ [expr {$sX * $xRef + $imX}] [expr {$sY * $yRef + $imY}] \ -text $textString \ -justify left \ -anchor $anchor \ -fill $color \ -font $font \ -angle $angle \ ] } $doc delete return $SvgTextItems } # ------------------------------------------------------------------------------ # Proc textForSvg::GetScaleFactors # ------------------------------------------------------------------------------ # Command to return scaling factors for conversion of SVG image coordinates to # canvas coordinates. # Valid only for case when viewBox attribute is supplied, and (if present) # height and width are numbers (not percentages or distances with units). # # Offset is not considered but in these pikchr examples is always (0, 0). # # Arguments: # doc - a document command returned by the tdom DOM parser. # # Return Value: list of two numbers, scale factors for x and y # ------------------------------------------------------------------------------ proc textForSvg::GetScaleFactors {doc} { set root [$doc documentElement] set attrList [$root attributes] if {{viewBox} ni $attrList} { return {1 1} } lassign [$root getAttribute viewBox] l u r d foreach varName {l u r d} { if {![string is double -strict [set $varName]]} { return {1 1} } } set dX [expr {$r - $l}] set dY [expr {$d - $u}] set sX 1 set sY 1 if { ({width} in $attrList) && [string is double -strict [set w [$root getAttribute width]]] } { set sX [expr {$w / ($dX + 0.)}] } if { ({height} in $attrList) && [string is double -strict [set h [$root getAttribute height]]] } { set sY [expr {$h / ($dY + 0.)}] } return [list $sX $sY] } # ------------------------------------------------------------------------------ # Proc textForSvg::GetColor # ------------------------------------------------------------------------------ # Command to convert value of text element attribute "fill" to a Tcl color. # # Recognizes only format fill="rgb(255,255,255)" which is the format used by # pikchr. # # Arguments: # fillValue - value of attribute "fill", or {} if attribute not supplied # default - return value if no fillValue # # Return Value: color in format #rrggbb # ------------------------------------------------------------------------------ proc textForSvg::GetColor {fillValue {default #000000}} { set pattern {rgb\((([^(), ]+),([^(), ]+),([^(), ]+))\)} if { ($fillValue ne {}) && [regexp -- $pattern $fillValue full rgbArgs r g b] && [string is integer -strict $r] && ($r >= 0) && ($r <= 255) && [string is integer -strict $g] && ($g >= 0) && ($g <= 255) && [string is integer -strict $b] && ($b >= 0) && ($b <= 255) } { # OK set color [format #%02x%02x%02x $r $g $b] } else { set color $default } return $color } # ------------------------------------------------------------------------------ # Proc textForSvg::GetRotation # ------------------------------------------------------------------------------ # Command to extract rotation parameters from the value of the "transform" # attribute. That value is assumed to have only a rotate() element; this is # sufficient for svg images generated by pikchr. # # Arguments: # trans - value of attribute "transform", or {} if attribute not supplied # # Return Value: list of three numbers: # - angle of rotation in degrees (anticlockwise) # - x value of centre of rotation in image coordinates # - y value of same # ------------------------------------------------------------------------------ proc textForSvg::GetRotation {trans} { set pattern {rotate\((([^() ,]+)[ ,]+([^(), ]+),([^(), ]+) *)\)} if { ($trans ne {}) && [regexp -- $pattern $trans full rotArgs angle originX originY] && [string is double -strict $angle] && [string is double -strict $originX] && [string is double -strict $originY] } { # OK } else { set angle 0.0 set originX 0.0 set originY 0.0 } list [expr {-1 * $angle}] $originX $originY } # ------------------------------------------------------------------------------ # Proc textForSvg::DictGetSafely # ------------------------------------------------------------------------------ # Command to read the value corresponding to a key in a dictionary; if the key # does not exist, don't raise an error (like dict get), instead return a default # value. # # Arguments: # dictionary - a dictionary value # keyList - the key list whose corresponding value is requested. An empty # list is treated as "key {}" rather than as "no argument". # default - (optional) value to return if key is not found in the dictionary # # Return Value: the value from the dictionary, or $default if the key is not # found # ------------------------------------------------------------------------------ proc textForSvg::DictGetSafely {dictionary keyList {default {}}} { if {$keyList eq {}} { set keyList [list {}] } if {[catch {dict get $dictionary {*}$keyList} value]} { set value $default } return $value } # ------------------------------------------------------------------------------ # Proc textForSvg::imageCreatePhoto # ------------------------------------------------------------------------------ # Command to create a Tk PNG image where the -data or -file option supplies a # SVG image with text. # # - Use this command if you need a pure image rather than a canvas that holds a # image and text canvas items. # - The command replaces "image create photo" for a SVG image and creates a # complete Tk image that includes any SVG text elements. It uses img::window # to process the image and draws a transient window on the screen. It # replaces transparent pixels with a background color specified by an # option/value pair. # - NOTE: The command is a SUBSTITUTE for "image create photo" but not an # EQUIVALENT. For example, it does not allow -data or -file to be specified # by "imageName configure" after image creation. # # Usage: # textForSvg::imageCreatePhoto ?name? ?option value ...? # # name - If specified, the name used for the image and its command. # If not specified, Tk assigns a name. # If specified as "--", an image is not created, and the return # value is the base64-encoded PNG image data, not an image name. # # Options (cf. Tk command "image create photo"): # -data - Specifies the image as SVG data in: # EITHER a binary string whose bytes represent text encoded in # utf-8. "image create photo" needs a binary string. and so # this is also the default for this command. # OR a standard Tcl string. Supply the arguments "-binary 0" to # identify this format to the command. # If the -data and -file options are specified, the -file # option takes precedence. # -format - IGNORED # -file - the name of a file that is to be read to supply data for the # photo image. The file format must be SVG. # -gamma - IGNORED # -height - Specifies the height of the image, in pixels. This option is # useful primarily in situations where the user wishes to build up # the contents of the image piece by piece. A value of zero (the # default) allows the image to expand or shrink vertically to # fit the data stored in it. # -metadata - IGNORED # -palette - IGNORED # -width - Specifies the width of the image, in pixels. This option is # useful primarily in situations where the user wishes to build up # the contents of the image piece by piece. A value of zero (the # default) allows the image to expand or shrink horizontally to # fit the data stored in it. # # Options (specific to this command): # -binary - (optional) boolean: if true (the default) any value supplied for # -data is a binary string with UTF-8 encoding, if false the value # is a Tcl string. Does not apply to an image read from -file. # -toplev - (optional) Tk window path of transient toplevel to use for the # conversion. Must not already exist. img::window requires a # toplevel whose name begins with a lower-case letter. # -transcolor - (optional) background color to be shown where the image is # transparent. Transparency is not preserved. # -scale - (optional) scale factor. # # Return Value: name of image command, or image data if argument "name" is "--" # ------------------------------------------------------------------------------ proc textForSvg::imageCreatePhoto {args} { set opts [ArgsToOpts {*}$args] set binary [dict get $opts -binary] set xmldata [dict get $opts -data] set name [dict get $opts -name] set tlev [dict get $opts -toplev] set bgColor [dict get $opts -transcolor] set fac [dict get $opts -scale] dict unset opts -binary dict unset opts -data dict unset opts -name dict unset opts -toplev dict unset opts -transcolor dict unset opts -scale # Leaves only -height -width. These default to 0. # ArgsToOpts ensures that $xmldata is always binary. if {$name ne {}} { set name [list $name] } set delay [cget -delay] package require img::window if {![string match -nocase *<svg* $xmldata]} { return -code error {argument xmldata is not a SVG image} } if {[catch {dom parse $xmldata} doc]} { return -code error {argument xmldata is not a valid SVG image} } else { $doc delete } if {[catch { set EnlargedSvgData [textForSvg::scaleSvg $xmldata $fac] set img1 [image create photo -data $EnlargedSvgData {*}$opts] toplevel $tlev wm overrideredirect $tlev canvas $tlev.can -width [image width $img1] \ -height [image height $img1] \ -bg $bgColor \ -highlightthickness 0 $tlev.can create image 0.0 0.0 -image $img1 -anchor nw textForSvg::addText $EnlargedSvgData $tlev.can 0 0 1 after idle [list pack $tlev.can] tkwait visibility $tlev.can after $delay set [namespace current]::Waiter($img1) 0 vwait [namespace current]::Waiter($img1) set img2 [image create photo -format window -data $tlev.can] set imgData [$img2 data -format png] if {($name eq {--}) && ([string range $imgData 0 4] eq {iVBOR})} { # Tk 8 package require base64 set img3 [base64::decode $imgData] } elseif {$name eq {--}} { # Tk 9 set img3 $imgData } else { set img3 [image create photo {*}$name -data $imgData {*}$opts] } destroy $tlev image delete $img1 image delete $img2 unset [namespace current]::Waiter($img1) } msg catchOpts]} { destroy $tlev catch {image delete $img1} catch {image delete $img2} catch {unset -nocomplain [namespace current]::Waiter($img1)} return -code error -options $catchOpts "error converting SVG image - $msg" } return $img3 } # ------------------------------------------------------------------------------ # Proc textForSvg::ArgsToOpts # ------------------------------------------------------------------------------ # Command to take the arguments of textForSvg::imageCreatePhoto and return # a dictionary of options. # # Arguments: # args: ?name? ?option value ...? # (see textForSvg::imageCreatePhoto usage) # # Return value: a dictionary with: # - key -name for argument "name", # - default values for options -binary, -name, -toplev, -transcolor, -scale if # values are not supplied by the caller, # - option -file replaced with -data from the filename value, # - non-handled options removed (except -height, -width). # - therefore has keys -binary -name -toplev -transcolor -scale -data -height # and -width # ------------------------------------------------------------------------------ proc textForSvg::ArgsToOpts {args} { set opts { -binary 1 -name {} -toplev .svg_conversion_in_textForSvg -transcolor #ffffff -scale 1.0 -width 0 -height 0 } if {[string index [lindex $args 0] 0] ne {-} || [lindex $args 0] eq {--}} { dict set opts -name [list [lindex $args 0]] set args [lrange $args 1 end] } if {[llength $args] % 2} { set args [lrange $args 0 end-1] set final [lindex $args end] set ok 0 } else { set ok 1 } set args [dict create {*}$args] # For each option with duplicates, keep the last value. if {[dict exists $args -file] && [dict exists $args -data]} { # Option -file overrides option -data. dict unset args -data } set UsingOptionFile [dict exists $args -file] foreach {opt val} $args { dict set opts {*}[ProcessOption $opt $val] } if {!$ok} { ProcessOption $final } # Note that [ProcessOption -file value] returns {-data DATA} where DATA is # a binary string. [ProcessOption -data value] returns {-data value}, and # -binary BOOL indicates whether "value" is binary. If it is not, we # convert it and always return -data as a binary string. if {![dict exists $opts -data]} { # We cannot use image configure to write the SVG image later, so # we require one of these options. return -code error "option \"-file\" or \"-data\" must be provided" } if {(![dict get $opts -binary]) && (!$UsingOptionFile)} { # Value for -data is a Tcl string. Convert to binary/utf-8. dict set opts -data [strictConvertTo [dict get $opts -data] utf-8] } return $opts } # ------------------------------------------------------------------------------ # Proc textForSvg::ProcessOption # ------------------------------------------------------------------------------ # Command to process an option/value pair (or an option without a value). # # Usage: textForSvg::ProcessOption option ?value? # Return Value: a list of 0 or 1 option/value pairs. 0 for a valid option that # is ignored; 1 for a non-ignored option. Option/value are passed through except # -file FILE which is converted to -data DATA which tries to be binary/utf-8. # ------------------------------------------------------------------------------ proc textForSvg::ProcessOption {args} { set opts {-binary -data -file -gamma -height -width -palette -metadata \ -format -transcolor -scale -toplev} set handled {-binary -data -file -height -width -transcolor -scale -toplev} set lenny [llength $args] if {$lenny ni {1 2}} { return -code error {internal error: bad call to ProcessOption} } lassign $args opt val if {$opt ni $opts} { return -code error "unknown option \"$opt\"" } if {$lenny == 1} { return -code error "value for \"$opt\" missing" } if {($opt ni $handled)} { # Silently ignore. return } if {$opt eq "-file" && [interp issafe]} { return -code error "no file access in a safe interpreter" } elseif {$opt eq "-file"} { # Fetch file into dat. # image(n) -data expects data in binary format. # Yes, this does apply to SVG. set fin [open $val] fconfigure $fin -translation binary set dat [read $fin] close $fin # - We need to return a binary string encoded as utf-8. # - When the system encoding is utf-8, we assume that the file is # encoded as utf-8. # - When the system encoding is something else, we try utf-8 first, and # then try the system encoding. If the file has the system encoding, # convert its data to binary/utf-8. if { ([encoding system] ne {utf-8}) && ( [catch {strictConvertFrom $dat utf-8}]) && (![catch {strictConvertFrom $dat [encoding system]} da2]) && (![catch {strictConvertTo $da2 utf-8} da3]) } { set dat $da3 # In other cases, return the original binary string "dat" that was # read from the file and has either utf-8 or undetermined encoding. } set args [list -data $dat] } return $args # The return value is either [list -data $dat] from the -file option, the # supplied arguments (all other cases that get this far), or {} (early # return for arguments that are not processed). } proc textForSvg::cget {option} { variable CONFIG if {![dict exists $CONFIG $option]} { return -code error "unknown option \"$option\"" } return [dict get $CONFIG $option value] } # Atomic. No validation of new values. proc textForSvg::configure {args} { variable CONFIG set lenny [llength $args] foreach {option value} $args { if {![dict exists $CONFIG $option]} { return -code error "unknown option \"$option\"" } } if {($lenny % 2) && ($lenny > 1)} { return -code error "value for \"$option\" missing" } # Error cases removed above. if {$lenny == 0} { set res {} foreach option [dict keys $CONFIG] { lappend res [configure $option] } return $res } elseif {$lenny == 1} { set option [lindex $args 0] return [dict values [dict get $CONFIG $option]] } elseif {$lenny == 2} { set option [lindex $args 0] set value [lindex $args 1] dict set CONFIG $option value $value return } else { foreach {option value} $args { dict set CONFIG $option value $value } return } } proc textForSvg::InitConfigure {defaultsDict} { variable CONFIG foreach {option default} $defaultsDict { dict set CONFIG $option [dict create option $option ns1 {} ns2 {} default $default value {}] } # Initialise values to defaults. foreach option [dict keys $CONFIG] { dict set CONFIG $option value [dict get $CONFIG $option default] } return } # Select a suitable font family from a list and a fallback. proc textForSvg::chooseFontFamily {fontList fallback} { foreach fnt $fontList { if {[fontIsPresent $fnt]} { return $fnt } } if {$fallback in [font names]} { return [font actual $fallback -family] } else { return [font actual [list $fallback] -family] } } # ------------------------------------------------------------------------------ # Proc textForSvg::strictConvertFrom # ------------------------------------------------------------------------------ # Command wrapper for "encoding convertfrom". Binary string -> Tcl string. # Attempts to convert a binary string to a Tcl string, assuming that the former # has a particular encoding. # # Returns with error status upon failure. Strict conversion, with failure # character reported in error message for Tcl 8 or 9. # # Arguments: # binString - the binary string to be interpreted. This must be a # binary string, either generated as such or read from a file # with suitable fconfigure settings. # enc - a valid encoding # # Return Value: Tcl string holding converted input # ------------------------------------------------------------------------------ proc textForSvg::strictConvertFrom {binString enc} { if {$enc ni [encoding names]} { return -code error "encoding \"$enc\" is not available" } if {[lindex [split $::tcl_version .] 0] eq {9}} { set tclString [encoding convertfrom -profile strict -failindex varFail $enc $binString] set validText [expr {$varFail == -1}] set suffix " at index $varFail" } else { set tclString [encoding convertfrom $enc $binString] # If the result is valid, the conversion will be reversible. # This is a useful test at least for UTF-8. set binString2 [encoding convertto $enc $tclString] set validText [expr {$binString eq $binString2}] if {$validText} { set suffix {} } else { for {set i 0} {$i < [string length $binString]} {incr i} { if {[string index $binString $i] ne [string index $binString2 $i]} { break } } set suffix " at index $i" } } if {!$validText} { return -code error "conversion from a binary string with\ encoding \"$enc\" to a Tcl string failed$suffix" } return $tclString } # ------------------------------------------------------------------------------ # Proc textForSvg::strictConvertTo # ------------------------------------------------------------------------------ # Command wrapper for "encoding convertto". Tcl string -> binary string. # Converts a Tcl string to a binary string whose bytes have a specific encoding. # # Returns with error status upon failure. Strict conversion, with failure # character reported in error message for Tcl 8 or 9. # # Arguments: # binString - the binary string to be interpreted. This must be a # binary string, either generated as such or read from a file # with suitable fconfigure settings. # enc - a valid encoding # # Return Value: Tcl string holding converted input # ------------------------------------------------------------------------------ proc textForSvg::strictConvertTo {tclString enc} { if {$enc ni [encoding names]} { return -code error "encoding \"$enc\" is not available" } if {[lindex [split $::tcl_version .] 0] eq {9}} { set binString [encoding convertto -profile strict -failindex varFail $enc $tclString] set validText [expr {$varFail == -1}] set suffix " at index $varFail" } else { set binString [encoding convertto $enc $tclString] # If the result is valid, the conversion will be reversible. # This is a useful test for UTF-8. set tclString2 [encoding convertfrom $enc $binString] set validText [expr {$tclString eq $tclString2}] if {$validText} { set suffix {} } else { for {set i 0} {$i < [string length $tclString]} {incr i} { if {[string index $tclString $i] ne [string index $tclString2 $i]} { break } } set suffix " at index $i" } } if {!$validText} { return -code error "conversion from a Tcl string to a binary string\ with encoding \"$enc\" failed$suffix" } return $binString } # Test whether a font family is present on the system. proc textForSvg::fontIsPresent {fam} { expr {[font actual [list $fam -16] -family] eq $fam} } # Return the font family that textForSvg uses by default in # one of three categories: Sans, Serif, and Mono. proc textForSvg::getDefaultFontFamily {style} { variable FontStyles if {![dict exists $FontStyles $style choice]} { return -code error "unknown style \"$style\"" } dict get $FontStyles $style choice } # Commands scaleSvg and ExtraScaleFactor are not related to rendering of SVG # text elements and do not depend on the other commands in this module. # ------------------------------------------------------------------------------ # Proc textForSvg::scaleSvg # ------------------------------------------------------------------------------ # Command to scale a SVG image. For a subset of SVG images. # # Arguments: # xmldata - svg image data (either binary string or Tcl string) # fac - scale factor # # Return Value: revised svg image data, same encoding as input # ------------------------------------------------------------------------------ proc textForSvg::scaleSvg {xmldata fac} { if {![string match -nocase *<svg* $xmldata]} { # Not valid SVG. Nothing to do. return $xmldata } if {[catch {dom parse $xmldata} doc]} { # Not valid XML. Nothing to do. return $xmldata } if {abs($fac - 1.0) < 1.E-3 || $fac > 33 || $fac < 0.03} { # Scale factor very close to 1, or too large, or too small return $xmldata } ExtraScaleFactor $doc $fac set newSvg [$doc asXML -indent none] $doc delete return $newSvg } # ------------------------------------------------------------------------------ # Proc textForSvg::ExtraScaleFactor # ------------------------------------------------------------------------------ # Command to scale a SVG image parsed by tdom. For a subset of SVG images. # # Arguments: # doc - a document command returned by the tdom DOM parser. # fac - scale factor # # Return Value: none # ------------------------------------------------------------------------------ proc textForSvg::ExtraScaleFactor {doc fac} { set root [$doc documentElement] set attrList [$root attributes] if { ({viewBox} ni $attrList) && (({height} ni $attrList) || ({width} ni $attrList)) } { # Would need to examine the coordinates of every element. return } if {{viewBox} ni $attrList} { # Construct viewBox from width, height, whose existence is guaranteed by # the previous test. if { [string is double -strict [set w [$root getAttribute width]]] && [string is double -strict [set h [$root getAttribute height]]] } { $root setAttribute viewBox "0 0 $w $h" } else { return } } # At this point the doc always has a viewBox. # If it started with a viewBox but without height and/or width, these # will be set below. lassign [$root getAttribute viewBox] l u r d foreach varName {l u r d} { if {![string is double -strict [set $varName]]} { return } } set dX [expr {$r - $l}] set dY [expr {$d - $u}] if { ({width} in $attrList) && [string is double -strict [set w [$root getAttribute width]]] } { set wX [expr {$w * $fac}] } else { set wX [expr {$dX * $fac}] } $root setAttribute width $wX if { ({height} in $attrList) && [string is double -strict [set h [$root getAttribute height]]] } { set hY [expr {$h * $fac}] } else { set hY [expr {$dY * $fac}] } $root setAttribute height $hY return } # Defines the dict FontStyles. # For the dict key "choice", call chooseFontFamily to choose the default fonts from those available. proc textForSvg::InitFontStyles {} { variable FontStyles {} set FontsSans {Arial \ {Droid Sans} Bahnschrift {MS Sans Serif} {Microsoft Sans Serif} \ {Helvetica Neue} Optima \ {Liberation Sans} {Nimbus Sans} {FreeSans} \ {Segoe UI}} set FontsSerif {{Times New Roman} \ {Californian FB} Centaur {MS Serif} Garamond Cambria Constantia \ Cochin Baskerville Charter \ {Liberation Serif} {Nimbus Roman} {FreeSerif}} set FontsMono {{Andale Mono} \ Consolas {Lucida Console} {Lucida Sans Typewriter} \ Menlo {PT Mono} Monaco \ {DejaVu Sans Mono} {Source Code Pro} \ {Liberation Mono} {Nimbus Mono PS} {FreeMono} \ {Courier New}} dict set FontStyles Sans [dict create list $FontsSans fallback TkDefaultFont] dict set FontStyles Serif [dict create list $FontsSerif fallback Times] dict set FontStyles Mono [dict create list $FontsMono fallback Courier] foreach kind {Sans Serif Mono} { set res [chooseFontFamily [dict get $FontStyles $kind list] [dict get $FontStyles $kind fallback]] dict set FontStyles $kind choice $res } return } # Command to initialise the module. Calls InitFontStyles for font discovery and InitConfigure to set cget/configure defaults and initial values. proc textForSvg::Init {} { variable FontStyles set defaultsDict { -delay 100 -defaultfont - -defaultheight 16 -monofont - -monoheight 13 } InitFontStyles dict set defaultsDict -defaultfont [dict get $FontStyles Sans choice] dict set defaultsDict -monofont [dict get $FontStyles Mono choice] InitConfigure $defaultsDict return } textForSvg::Init package provide textForSvg 1.0b1 |
Changes to support/devel/sak/doc/kwic.txt.
︙ | ︙ | |||
553 554 555 556 557 558 559 560 561 562 563 564 565 566 | [manpage modules/map/track-store-mem.man map::track::store::memory] [key {store, geobox, filesystem}] [manpage modules/map/box-store-fs.man map::box::store::fs] [key string] [manpage modules/getstring/tk_getString.man getstring] [key superframe] [manpage modules/widget/widget.man widget] [key {syntax highlighting}] [manpage modules/ctext/ctext.man ctext] [key {tabular, area display}] [manpage modules/map/area-display.man map::area::display] [manpage modules/map/area-table-display.man map::area::table-display] [key {tabular, box display}] [manpage modules/map/box-display.man map::box::display] | > > | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | [manpage modules/map/track-store-mem.man map::track::store::memory] [key {store, geobox, filesystem}] [manpage modules/map/box-store-fs.man map::box::store::fs] [key string] [manpage modules/getstring/tk_getString.man getstring] [key superframe] [manpage modules/widget/widget.man widget] [key svg] [manpage modules/textForSvg/textForSvg.man textForSvg] [key {syntax highlighting}] [manpage modules/ctext/ctext.man ctext] [key {tabular, area display}] [manpage modules/map/area-display.man map::area::display] [manpage modules/map/area-table-display.man map::area::table-display] [key {tabular, box display}] [manpage modules/map/box-display.man map::box::display] |
︙ | ︙ |
Changes to support/devel/sak/doc/manpages.txt.
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | modules/ntext/ntextWordBreak.man modules/persistentSelection/persistentSelection.man modules/plotchart/plotchart.man modules/shtmlview/shtmlview-doctools.man modules/shtmlview/shtmlview-mkdoc.man modules/shtmlview/shtmlview.man modules/swaplist/swaplist.man modules/tkpiechart/canvaslabel.man modules/tkpiechart/pie.man modules/tkpiechart/pieboxlabeler.man modules/tkpiechart/pieperipherallabeler.man modules/tooltip/tipstack.man modules/tooltip/tooltip.man modules/widget/widget.man | > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | modules/ntext/ntextWordBreak.man modules/persistentSelection/persistentSelection.man modules/plotchart/plotchart.man modules/shtmlview/shtmlview-doctools.man modules/shtmlview/shtmlview-mkdoc.man modules/shtmlview/shtmlview.man modules/swaplist/swaplist.man modules/textForSvg/textForSvg.man modules/tkpiechart/canvaslabel.man modules/tkpiechart/pie.man modules/tkpiechart/pieboxlabeler.man modules/tkpiechart/pieperipherallabeler.man modules/tooltip/tipstack.man modules/tooltip/tooltip.man modules/widget/widget.man |
︙ | ︙ |
Changes to support/devel/sak/doc/toc.txt.
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [item modules/plotchart/plotchart.man Plotchart {Simple plotting and charting package}] [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [item modules/tooltip/tipstack.man tipstack {Stacked tooltips}] [item modules/tooltip/tooltip.man tooltip {Tooltip management}] [item modules/widgetl/widget_listentry.man widget_listentry {widget::listentry widget}] [item modules/widgetl/widget_listsimple.man widget_listsimple {widget::listsimple widget}] [item modules/widgetv/widget_validator.man widget_validator {widget::validator behaviour}] [item modules/widgetPlus/widgetPlus.man widgetPlus {Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features}] [division_end] | > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [item modules/plotchart/plotchart.man Plotchart {Simple plotting and charting package}] [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [item modules/textForSvg/textForSvg.man textForSvg {Render Text In SVG Images}] [item modules/tooltip/tipstack.man tipstack {Stacked tooltips}] [item modules/tooltip/tooltip.man tooltip {Tooltip management}] [item modules/widgetl/widget_listentry.man widget_listentry {widget::listentry widget}] [item modules/widgetl/widget_listsimple.man widget_listsimple {widget::listsimple widget}] [item modules/widgetv/widget_validator.man widget_validator {widget::validator behaviour}] [item modules/widgetPlus/widgetPlus.man widgetPlus {Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features}] [division_end] |
︙ | ︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 | [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [division_end] [division_start swaplist] [item modules/swaplist/swaplist.man swaplist {A dialog which allows a user to move options between two lists}] [division_end] [division_start tkpiechart] [item modules/tkpiechart/canvaslabel.man canvasLabel {tkpiechart canvas label class}] [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [division_end] [division_start tooltip] | > > > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [division_end] [division_start swaplist] [item modules/swaplist/swaplist.man swaplist {A dialog which allows a user to move options between two lists}] [division_end] [division_start textForSvg] [item modules/textForSvg/textForSvg.man textForSvg {Render Text In SVG Images}] [division_end] [division_start tkpiechart] [item modules/tkpiechart/canvaslabel.man canvasLabel {tkpiechart canvas label class}] [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [division_end] [division_start tooltip] |
︙ | ︙ |
Changes to support/devel/sak/doc/toc_cats.txt.
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [item modules/plotchart/plotchart.man Plotchart {Simple plotting and charting package}] [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [item modules/tooltip/tipstack.man tipstack {Stacked tooltips}] [item modules/tooltip/tooltip.man tooltip {Tooltip management}] [item modules/widgetl/widget_listentry.man widget_listentry {widget::listentry widget}] [item modules/widgetl/widget_listsimple.man widget_listsimple {widget::listsimple widget}] [item modules/widgetv/widget_validator.man widget_validator {widget::validator behaviour}] [item modules/widgetPlus/widgetPlus.man widgetPlus {Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features}] [division_end] | > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [item modules/plotchart/plotchart.man Plotchart {Simple plotting and charting package}] [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [item modules/textForSvg/textForSvg.man textForSvg {Render Text In SVG Images}] [item modules/tooltip/tipstack.man tipstack {Stacked tooltips}] [item modules/tooltip/tooltip.man tooltip {Tooltip management}] [item modules/widgetl/widget_listentry.man widget_listentry {widget::listentry widget}] [item modules/widgetl/widget_listsimple.man widget_listsimple {widget::listsimple widget}] [item modules/widgetv/widget_validator.man widget_validator {widget::validator behaviour}] [item modules/widgetPlus/widgetPlus.man widgetPlus {Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features}] [division_end] |
︙ | ︙ |
Changes to support/devel/sak/doc/toc_mods.txt.
︙ | ︙ | |||
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [division_end] [division_start swaplist] [item modules/swaplist/swaplist.man swaplist {A dialog which allows a user to move options between two lists}] [division_end] [division_start tkpiechart] [item modules/tkpiechart/canvaslabel.man canvasLabel {tkpiechart canvas label class}] [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [division_end] [division_start tooltip] | > > > | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | [item modules/shtmlview/shtmlview.man shtmlview {Extended Tcl/Tk text widget with basic support for rendering of HTML and Markdown}] [item modules/shtmlview/shtmlview-doctools.man shtmlview_doctools {shtmlview extension adding support for doctools markup}] [item modules/shtmlview/shtmlview-mkdoc.man shtmlview_mkdoc {shtmlview extension adding support for mkdoc markup}] [division_end] [division_start swaplist] [item modules/swaplist/swaplist.man swaplist {A dialog which allows a user to move options between two lists}] [division_end] [division_start textForSvg] [item modules/textForSvg/textForSvg.man textForSvg {Render Text In SVG Images}] [division_end] [division_start tkpiechart] [item modules/tkpiechart/canvaslabel.man canvasLabel {tkpiechart canvas label class}] [item modules/tkpiechart/pie.man pie {2D or 3D pie chart object in a canvas}] [item modules/tkpiechart/pieboxlabeler.man pieBoxLabeler {tkpiechart pie box style labeler class}] [item modules/tkpiechart/pieperipherallabeler.man piePeripheralLabeler {tkpiechart pie peripheral style labeler class}] [division_end] [division_start tooltip] |
︙ | ︙ |
Changes to support/installation/modules.tcl.
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | Module plotchart _tcl _man _exa Module scrollutil _tab _null _exa Module shtmlview _tcl _man _null Module style _tcl _man _null Module swaplist _tcl _man _null Module tablelist _tab _null _exa Module text _tcl _null _null Module tkpiechart _tcl _man _exa Module tooltip _tcl _man _null Module treeview _tcl _null _null Module tsw _tab _null _exa Module wcb _tab _null _exa Module widget _tcl _man _exa Module widgetPlus _tcl _man _exa | > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | Module plotchart _tcl _man _exa Module scrollutil _tab _null _exa Module shtmlview _tcl _man _null Module style _tcl _man _null Module swaplist _tcl _man _null Module tablelist _tab _null _exa Module text _tcl _null _null Module textForSvg _tcl _man _exa Module tkpiechart _tcl _man _exa Module tooltip _tcl _man _null Module treeview _tcl _null _null Module tsw _tab _null _exa Module wcb _tab _null _exa Module widget _tcl _man _exa Module widgetPlus _tcl _man _exa |
︙ | ︙ |
Changes to support/releases/PACKAGES.
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | style::as 1.4.1 style::lobster 0.2 swaplist 0.2 tablelist 7.4.1 tablelist::common 7.4.1 tablelist_tile 7.4.1 tachometer 0.2 tipstack 1.0.1 tkpiechart 6.6.1 tooltip 2.0.1 voltmeter 0.2 wcb 4.1.1 widget 3.2 widget::arrowbutton 1.0 | > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | style::as 1.4.1 style::lobster 0.2 swaplist 0.2 tablelist 7.4.1 tablelist::common 7.4.1 tablelist_tile 7.4.1 tachometer 0.2 textForSvg 1.0b1 tipstack 1.0.1 tkpiechart 6.6.1 tooltip 2.0.1 voltmeter 0.2 wcb 4.1.1 widget 3.2 widget::arrowbutton 1.0 |
︙ | ︙ |
Changes to support/releases/history/README-0.9.md.
1 2 3 4 5 6 7 8 | Overview ======== |||||| |---:|:---|:---|---:|:---| |22|changed packages|in|16|modules| |29|internally changed packages|in|2|modules| |65|unchanged packages|in|24|modules| | > | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | Overview ======== |||||| |---:|:---|:---|---:|:---| |1|new packages|in|1|modules| |22|changed packages|in|16|modules| |29|internally changed packages|in|2|modules| |65|unchanged packages|in|24|modules| |124|packages, total|in|36|modules, total| Legend ====== |Change|Details|Comments| |:---|:---|:---| |Major|API|__incompatible__ API changes| |Minor|EF|Extended functionality, API| ||I|Major rewrite, but no API change| |Patch|B|Bug fixes| ||EX|New examples| ||P|Performance enhancement| |None|T|Testsuite changes| ||D|Documentation updates| New in Tklib 0.9 ================ |Module|Package|New Version|Comments| |:---|:---|:---|:---| |textForSvg|textForSvg|1.0b1|| ||||| Changes from Tklib 0.8 to 0.9 ============================= |Module|Package|From 0.8|To 0.9|Comments| |:---|:---|:---|:---|:---| |controlwidget|tachometer|0.1|0.2|I| |
︙ | ︙ |
Changes to support/releases/history/README-0.9.txt.
1 2 3 4 5 6 | Overview ======== 22 changed packages in 16 modules 29 internally changed packages in 2 modules 65 unchanged packages in 24 modules | > | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | Overview ======== 1 new packages in 1 modules 22 changed packages in 16 modules 29 internally changed packages in 2 modules 65 unchanged packages in 24 modules 124 packages, total in 36 modules, total Legend ====== Change Details Comments -------- --------- ---------------------------------- Major API __incompatible__ API changes Minor EF Extended functionality, API I Major rewrite, but no API change Patch B Bug fixes EX New examples P Performance enhancement None T Testsuite changes D Documentation updates -------- --------- ---------------------------------- New in Tklib 0.9 ================ Module Package New Version Comments ----------- --------------------------- ------------- ---------- textForSvg textForSvg 1.0b1 ----------- --------------------------- ------------- ---------- Changes from Tklib 0.8 to 0.9 ============================= Module Package From 0.8 To 0.9 Comments --------------- ---------------------- ---------- -------- ---------- controlwidget tachometer 0.1 0.2 I voltmeter 0.1 0.2 I |
︙ | ︙ |