Debian Codegraph @

texmf-dist/fonts/source/public/dice/dice3d.mf

raw
1 % DICE3D.MF
2 %
3 % by Thomas A. Heim (1998)
4 %
5 % 3D-look for dice; works reasonably well only in display size 20pt and up
6 %
7 % 2D-pictures are characters 1,2,3,4,5,6;
8 % 3D-pictures are characters "a" through "x",
9 % but they're accessible using ligatures #a, #b, #c, #d,
10 % where # is the value on the top face, and
11 % the letter indicates one of the four possible
12 % values on the front face: "a" -> smallest, "d" -> largest
13 %
14 % alternatively, there are ligature tables so that
15 % the letters run from "a" to "f", indicating 1 to 6 dots
16 % on the front face
17 %
18 % (you can change the lig table at the end of the file)
19 %
20 % LICENSE: LPPL
21 %
22
23 % change this to get a different size
24 size_in_points = 30;
25
26 mode_setup;
27
28 % autorounding := 0; % no need to shut off autorounding
29 % smoothing := 0; % or smoothing
30
31 % define the unit size
32 un#=(size_in_points/10) * pt#;
33 define_whole_pixels(un);
34
35 font_normal_space 3un#;
36
37 % amount of space to the left and right of dice box;
38 % if you change this, also change the 2nd parameter to
39 % beginchar for each character
40 sb = .5 un;
41
42 % size of dots on front face
43 DotSize = .8un;
44
45 % width and height of front face
46 face_width = 8un;
47 face_height = 8un;
48
49 % amount of rounding at corners
50 dice_c = 1.3DotSize;
51
52 % transformations front -> side, front -> top, scale with 1/sqrt(8):
53 sqrt_eight = 0.35355339;
54
55 % scaled dot diagonal
56 dot_xy = sqrt_eight*DotSize;
57
58 % define the affine transformations front->side, front->top
59 transform t[];
60
61 hide( (0,0) transformed t1 = (0,0) );
62 hide( (1,0) transformed t1 = (sqrt_eight,sqrt_eight) );
63 hide( (0,1) transformed t1 = (0,1) );
64 hide( (0,0) transformed t2 = (0,0) );
65 hide( (1,0) transformed t2 = (1,0) );
66 hide( (0,1) transformed t2 = (sqrt_eight,sqrt_eight) );
67
68 % t3 transforms front to right side
69 t3 = t1 shifted (face_width,0);
70
71 % t4 transforms front to top
72 t4 = t2 shifted (0,face_height);
73
74 % the following macro draws a die face, with rounded corners
75 def dice_face =
76 begingroup;
77 save w, h;
78 numeric w[], h[];
79
80 lft w1 = sb = w2 - dice_c = w3 - face_width + dice_c = rt w4 - face_width;
81 bot h1 = 0 = h2 - dice_c = h3 - face_height + dice_c = top h4 - face_height;
82
83 draw (w1,h2)---(w1, h3)..(w2, h4)---(w3,h4)..(w4,h3)---
84 (w4,h2)..(w3,h1)---(w2,h1)..cycle;
85
86 endgroup;
87
88 enddef;
89
90 % the following macro draws a box, with rounded corners
91 def dice_box =
92 begingroup;
93 save w, h;
94 numeric w[], h[];
95
96 lft w1 = sb = w2 - dice_c = w3 - face_width + dice_c = rt w4 - face_width;
97 bot h1 = 0 = h2 - dice_c = h3 - face_height + dice_c = top h4 - face_height;
98
99 % the front face:
100 draw (w1,h2)---(w1, h3)..(w2, h4)---(w3,h4)..(w4,h3)---
101 (w4,h2)..(w3,h1)---(w2,h1)..cycle;
102
103 % the right side face:
104 draw ((w1,h2) transformed t3)---((w1,h3) transformed t3)..
105 ((w2,h4) transformed t3)---((w3,h4) transformed t3)..
106 ((w4,h3) transformed t3)---((w4,h2) transformed t3)..
107 ((w3,h1) transformed t3)---((w2,h1) transformed t3)..cycle;
108
109 % the top face:
110 draw ((w1,h2) transformed t4)---((w1,h3) transformed t4)..
111 ((w2,h4) transformed t4)---((w3,h4) transformed t4)..
112 ((w4,h3) transformed t4)---((w4,h2) transformed t4)..
113 ((w3,h1) transformed t4)---((w2,h1) transformed t4)..cycle;
114
115 % connect upper left front to top:
116 draw (w1,h3)..((w1,h2) transformed t4);
117
118 endgroup;
119 enddef;
120
121 % the following macros draw dots on the front, side, and top,
122 % with the appropriate transformations, at point z$:
123
124 def front_dot (suffix $) =
125 fill (z$+(0,DotSize)){right}..{left}(z$-(0,DotSize))..cycle;
126 enddef;
127
128 def side_dot (suffix $) =
129 fill (z$+(dot_xy,dot_xy)){up}.. {dir 225}(z$+(0,DotSize)){dir 225}..
130 {down}(z$-(dot_xy,dot_xy)){down}..{dir 45}(z$-(0,DotSize))..cycle;
131 enddef;
132
133 def top_dot (suffix $) =
134 fill (z$+(dot_xy,dot_xy)){right}..{dir 225}(z$+(DotSize,0)){dir 225}..
135 {left}(z$-(dot_xy,dot_xy)){left}..{dir 45}(z$-(DotSize,0))..cycle;
136 enddef;
137
138 def dice_dots =
139 % this macros defines the possible dot positions:
140 % dots are labeled z1 through z27 as follows
141 % _____________
142 % / 19 20 21 / |
143 % / 22 23 24 / 12|
144 % / 25 26 27 / 11 |
145 % ------------- 10 15|
146 % | 1 2 3 | 14 | i.e., 1-9 on front,
147 % | | 13 18| 10-18 on side,
148 % | 4 5 6 | 17 / 19-27 on top
149 % | | 16 /
150 % | 7 8 9 | /
151 % -------------/
152 %
153 % the nine positions for dots on the front face:
154 x1 = sb + face_width/4 = x2 - face_width/4 = x3 - face_width/2 = x4 = x7;
155 x5 = x2 = x8;
156 x6 = x3 = x9;
157 y1 = 3/4face_height = y2 = y3;
158 y4 = face_height/2 = y5 = y6;
159 y7 = face_height/4 = y8 = y9;
160 % nine dot positions on the right side face:
161 % (1st and 3rd column are shifted towards the center to avoid
162 % overlap with frame)
163 z10 = (z1 shifted (sb,0)) transformed t3;
164 z11 = z2 transformed t3;
165 z12 = (z3 shifted (-sb,0)) transformed t3;
166 z13 = (z4 shifted (sb,0)) transformed t3;
167 z14 = z5 transformed t3;
168 z15 = (z6 shifted (-sb,0)) transformed t3;
169 z16 = (z7 shifted (sb,0)) transformed t3;
170 z17 = z8 transformed t3;
171 z18 = (z9 shifted (-sb,0)) transformed t3;
172 % nine dot positions on the top face:
173 % (1st and 3rd row are shifted towards the center to avoid
174 % overlap with frame)
175 z19 = (z1 shifted (0,-sb)) transformed t4;
176 z20 = (z2 shifted (0,-sb)) transformed t4;
177 z21 = (z3 shifted (0,-sb)) transformed t4;
178 z22 = z4 transformed t4;
179 z23 = z5 transformed t4;
180 z24 = z6 transformed t4;
181 z25 = (z7 shifted (0,sb)) transformed t4;
182 z26 = (z8 shifted (0,sb)) transformed t4;
183 z27 = (z9 shifted (0,sb)) transformed t4;
184 enddef;
185
186 % the 2D faces:
187 beginchar("1",9un#,8un#,0); "One";
188
189 pickup pencircle scaled .5 un;
190
191 dice_face; % draw the frame
192 dice_dots; % get the dot positions
193 front_dot(5); % draw a dot
194
195 endchar;
196
197 beginchar("2",9un#,8un#,0); "Two";
198
199 pickup pencircle scaled .5 un;
200
201 dice_face; % draw the frame
202 dice_dots; % get the dot positions
203 front_dot(1); % draw a dot
204 front_dot(9); % draw a dot
205
206 endchar;
207
208 beginchar("3",9un#,8un#,0); "Three";
209
210 pickup pencircle scaled .5 un;
211
212 dice_face; % draw the frame
213 dice_dots; % get the dot positions
214 front_dot(1); % draw a dot
215 front_dot(5); % draw a dot
216 front_dot(9); % draw a dot
217
218 endchar;
219
220 beginchar("4",9un#,8un#,0); "Four";
221
222 pickup pencircle scaled .5 un;
223
224 dice_face; % draw the frame
225 dice_dots; % get the dot positions
226 front_dot(1); % draw a dot
227 front_dot(3); % draw a dot
228 front_dot(7); % draw a dot
229 front_dot(9); % draw a dot
230
231 endchar;
232
233 beginchar("5",9un#,8un#,0); "Five";
234
235 pickup pencircle scaled .5 un;
236
237 dice_face; % draw the frame
238 dice_dots; % get the dot positions
239 front_dot(1); % draw a dot
240 front_dot(3); % draw a dot
241 front_dot(5); % draw a dot
242 front_dot(7); % draw a dot
243 front_dot(9); % draw a dot
244
245 endchar;
246
247 beginchar("6",9un#,8un#,0); "Six";
248
249 pickup pencircle scaled .5 un;
250
251 dice_face; % draw the frame
252 dice_dots; % get the dot positions
253 front_dot(1); % draw a dot
254 front_dot(3); % draw a dot
255 front_dot(4); % draw a dot
256 front_dot(6); % draw a dot
257 front_dot(7); % draw a dot
258 front_dot(9); % draw a dot
259
260 endchar;
261
262 % the 3D dice:
263 beginchar("a",12un#,12un#,0); "OneTwoThree";
264
265 pickup pencircle scaled .5 un;
266
267 % draw the box
268 dice_box;
269
270 % get the dot positions
271 dice_dots;
272
273 % dots
274 top_dot(23);
275 front_dot(1);
276 front_dot(9);
277 side_dot(10);
278 side_dot(14);
279 side_dot(18);
280 endchar;
281
282 beginchar("b",12un#,12un#,0); "OneThreeFive";
283
284 pickup pencircle scaled .5 un;
285
286 % draw the box
287 dice_box;
288
289 % get the dot positions
290 dice_dots;
291
292 % dots
293 top_dot(23);
294 front_dot(1);
295 front_dot(5);
296 front_dot(9);
297 side_dot(10);
298 side_dot(12);
299 side_dot(14);
300 side_dot(16);
301 side_dot(18);
302
303 endchar;
304
305 beginchar("c",12un#,12un#,0); "OneFourTwo";
306
307 pickup pencircle scaled .5 un;
308
309 % draw the box
310 dice_box;
311
312 % get the dot positions
313 dice_dots;
314
315 % dots
316 top_dot(23);
317 front_dot(1);
318 front_dot(3);
319 front_dot(7);
320 front_dot(9);
321 side_dot(10);
322 side_dot(18);
323
324 endchar;
325
326 beginchar("d",12un#,12un#,0); "OneFiveFour";
327
328 pickup pencircle scaled .5 un;
329
330 % draw the box
331 dice_box;
332
333 % get the dot positions
334 dice_dots;
335
336 % dots
337 top_dot(23);
338 front_dot(1);
339 front_dot(3);
340 front_dot(5);
341 front_dot(7);
342 front_dot(9);
343 side_dot(10);
344 side_dot(12);
345 side_dot(16);
346 side_dot(18);
347
348 endchar;
349
350 beginchar("e",12un#,12un#,0); "TwoOneFour";
351
352 pickup pencircle scaled .5 un;
353
354 % draw the box
355 dice_box;
356
357 % get the dot positions
358 dice_dots;
359
360 % dots
361 top_dot(19);
362 top_dot(27);
363 front_dot(5);
364 side_dot(10);
365 side_dot(12);
366 side_dot(16);
367 side_dot(18);
368
369 endchar;
370
371 beginchar("f",12un#,12un#,0); "TwoThreeOne";
372
373 pickup pencircle scaled .5 un;
374
375 % draw the box
376 dice_box;
377
378 % get the dot positions
379 dice_dots;
380
381 % dots
382 top_dot(21);
383 top_dot(25);
384 front_dot(3);
385 front_dot(5);
386 front_dot(7);
387 side_dot(14);
388
389 endchar;
390
391 beginchar("g",12un#,12un#,0); "TwoFourSix";
392
393 pickup pencircle scaled .5 un;
394
395 % draw the box
396 dice_box;
397
398 % get the dot positions
399 dice_dots;
400
401 % dots
402 top_dot(21);
403 top_dot(25);
404 front_dot(1);
405 front_dot(3);
406 front_dot(7);
407 front_dot(9);
408 side_dot(10);
409 side_dot(12);
410 side_dot(13);
411 side_dot(15);
412 side_dot(16);
413 side_dot(18);
414
415 endchar;
416
417 beginchar("h",12un#,12un#,0); "TwoSixThree";
418
419 pickup pencircle scaled .5 un;
420
421 % draw the box
422 dice_box;
423
424 % get the dot positions
425 dice_dots;
426
427 % dots
428 top_dot(19);
429 top_dot(27);
430 front_dot(1);
431 front_dot(3);
432 front_dot(4);
433 front_dot(6);
434 front_dot(7);
435 front_dot(9);
436 side_dot(12);
437 side_dot(14);
438 side_dot(16);
439
440 endchar;
441
442 beginchar("i",12un#,12un#,0); "ThreeOneTwo";
443
444 pickup pencircle scaled .5 un;
445
446 % draw the box
447 dice_box;
448
449 % get the dot positions
450 dice_dots;
451
452 % dots
453 top_dot(19);
454 top_dot(23);
455 top_dot(27);
456 front_dot(5);
457 side_dot(12);
458 side_dot(16);
459
460 endchar;
461
462 beginchar("j",12un#,12un#,0); "ThreeTwoSix";
463
464 pickup pencircle scaled .5 un;
465
466 % draw the box
467 dice_box;
468
469 % get the dot positions
470 dice_dots;
471
472 % dots
473 top_dot(21);
474 top_dot(23);
475 top_dot(25);
476 front_dot(3);
477 front_dot(7);
478 side_dot(10);
479 side_dot(11);
480 side_dot(12);
481 side_dot(16);
482 side_dot(17);
483 side_dot(18);
484
485 endchar;
486
487 beginchar("k",12un#,12un#,0); "ThreeFiveOne";
488
489 pickup pencircle scaled .5 un;
490
491 % draw the box
492 dice_box;
493
494 % get the dot positions
495 dice_dots;
496
497 % dots
498 top_dot(21);
499 top_dot(23);
500 top_dot(25);
501 front_dot(1);
502 front_dot(3);
503 front_dot(5);
504 front_dot(7);
505 front_dot(9);
506 side_dot(14);
507
508 endchar;
509
510 beginchar("l",12un#,12un#,0); "ThreeSixFive";
511
512 pickup pencircle scaled .5 un;
513
514 % draw the box
515 dice_box;
516
517 % get the dot positions
518 dice_dots;
519
520 % dots
521 top_dot(19);
522 top_dot(23);
523 top_dot(27);
524 front_dot(1);
525 front_dot(2);
526 front_dot(3);
527 front_dot(7);
528 front_dot(8);
529 front_dot(9);
530 side_dot(10);
531 side_dot(12);
532 side_dot(14);
533 side_dot(16);
534 side_dot(18);
535
536 endchar;
537
538 beginchar("m",12un#,12un#,0); "FourOneFive";
539
540 pickup pencircle scaled .5 un;
541
542 % draw the box
543 dice_box;
544
545 % get the dot positions
546 dice_dots;
547
548 % dots
549 top_dot(19);
550 top_dot(21);
551 top_dot(25);
552 top_dot(27);
553 front_dot(5);
554 side_dot(10);
555 side_dot(12);
556 side_dot(14);
557 side_dot(16);
558 side_dot(18);
559
560 endchar;
561
562 beginchar("n",12un#,12un#,0); "FourTwoOne";
563
564 pickup pencircle scaled .5 un;
565
566 % draw the box
567 dice_box;
568
569 % get the dot positions
570 dice_dots;
571
572 % dots
573 top_dot(19);
574 top_dot(21);
575 top_dot(25);
576 top_dot(27);
577 front_dot(3);
578 front_dot(7);
579 side_dot(14);
580
581 endchar;
582
583 beginchar("o",12un#,12un#,0); "FourFiveSix";
584
585 pickup pencircle scaled .5 un;
586
587 % draw the box
588 dice_box;
589
590 % get the dot positions
591 dice_dots;
592
593 % dots
594 top_dot(19);
595 top_dot(21);
596 top_dot(25);
597 top_dot(27);
598 front_dot(1);
599 front_dot(3);
600 front_dot(5);
601 front_dot(7);
602 front_dot(9);
603 side_dot(10);
604 side_dot(11);
605 side_dot(12);
606 side_dot(16);
607 side_dot(17);
608 side_dot(18);
609
610 endchar;
611
612 beginchar("p",12un#,12un#,0); "FourSixTwo";
613
614 pickup pencircle scaled .5 un;
615
616 % draw the box
617 dice_box;
618
619 % get the dot positions
620 dice_dots;
621
622 % dots
623 top_dot(19);
624 top_dot(21);
625 top_dot(25);
626 top_dot(27);
627 front_dot(1);
628 front_dot(2);
629 front_dot(3);
630 front_dot(7);
631 front_dot(8);
632 front_dot(9);
633 side_dot(12);
634 side_dot(16);
635
636 endchar;
637
638 beginchar("q",12un#,12un#,0); "FiveOneThree";
639
640 pickup pencircle scaled .5 un;
641
642 % draw the box
643 dice_box;
644
645 % get the dot positions
646 dice_dots;
647
648 % dots
649 top_dot(19);
650 top_dot(21);
651 top_dot(23);
652 top_dot(25);
653 top_dot(27);
654 front_dot(5);
655 side_dot(12);
656 side_dot(14);
657 side_dot(16);
658
659 endchar;
660
661 beginchar("r",12un#,12un#,0); "FiveThreeSix";
662
663 pickup pencircle scaled .5 un;
664
665 % draw the box
666 dice_box;
667
668 % get the dot positions
669 dice_dots;
670
671 % dots
672 top_dot(19);
673 top_dot(21);
674 top_dot(23);
675 top_dot(25);
676 top_dot(27);
677 front_dot(3);
678 front_dot(5);
679 front_dot(7);
680 side_dot(10);
681 side_dot(12);
682 side_dot(13);
683 side_dot(15);
684 side_dot(16);
685 side_dot(18);
686
687 endchar;
688
689 beginchar("s",12un#,12un#,0); "FiveFourOne";
690
691 pickup pencircle scaled .5 un;
692
693 % draw the box
694 dice_box;
695
696 % get the dot positions
697 dice_dots;
698
699 % dots
700 top_dot(19);
701 top_dot(21);
702 top_dot(23);
703 top_dot(25);
704 top_dot(27);
705 front_dot(1);
706 front_dot(3);
707 front_dot(7);
708 front_dot(9);
709 side_dot(14);
710
711 endchar;
712
713 beginchar("t",12un#,12un#,0); "FiveSixFour";
714
715 pickup pencircle scaled .5 un;
716
717 % draw the box
718 dice_box;
719
720 % get the dot positions
721 dice_dots;
722 top_dot(19);
723 top_dot(21);
724 top_dot(23);
725 top_dot(25);
726 top_dot(27);
727 front_dot(1);
728 front_dot(3);
729 front_dot(4);
730 front_dot(6);
731 front_dot(7);
732 front_dot(9);
733 side_dot(10);
734 side_dot(12);
735 side_dot(16);
736 side_dot(18);
737
738 % dots
739
740 endchar;
741
742 beginchar("u",12un#,12un#,0); "SixTwoFour";
743
744 pickup pencircle scaled .5 un;
745
746 % draw the box
747 dice_box;
748
749 % get the dot positions
750 dice_dots;
751
752 % dots
753 top_dot(19);
754 top_dot(21);
755 top_dot(22);
756 top_dot(24);
757 top_dot(25);
758 top_dot(27);
759 front_dot(1);
760 front_dot(9);
761 side_dot(10);
762 side_dot(12);
763 side_dot(16);
764 side_dot(18);
765
766 endchar;
767
768 beginchar("v",12un#,12un#,0); "SixThreeTwo";
769
770 pickup pencircle scaled .5 un;
771
772 % draw the box
773 dice_box;
774
775 % get the dot positions
776 dice_dots;
777
778 % dots
779 top_dot(19);
780 top_dot(20);
781 top_dot(21);
782 top_dot(25);
783 top_dot(26);
784 top_dot(27);
785 front_dot(1);
786 front_dot(5);
787 front_dot(9);
788 side_dot(10);
789 side_dot(18);
790
791 endchar;
792
793 beginchar("w",12un#,12un#,0); "SixFourFive";
794
795 pickup pencircle scaled .5 un;
796
797 % draw the box
798 dice_box;
799
800 % get the dot positions
801 dice_dots;
802
803 % dots
804 top_dot(19);
805 top_dot(20);
806 top_dot(21);
807 top_dot(25);
808 top_dot(26);
809 top_dot(27);
810 front_dot(1);
811 front_dot(3);
812 front_dot(7);
813 front_dot(9);
814 side_dot(10);
815 side_dot(12);
816 side_dot(14);
817 side_dot(16);
818 side_dot(18);
819
820 endchar;
821
822 beginchar("x",12un#,12un#,0); "SixFiveThree";
823
824 pickup pencircle scaled .5 un;
825
826 % draw the box
827 dice_box;
828
829 % get the dot positions
830 dice_dots;
831
832 % dots
833 top_dot(19);
834 top_dot(21);
835 top_dot(22);
836 top_dot(24);
837 top_dot(25);
838 top_dot(27);
839 front_dot(1);
840 front_dot(3);
841 front_dot(5);
842 front_dot(7);
843 front_dot(9);
844 side_dot(10);
845 side_dot(14);
846 side_dot(18);
847
848 endchar;
849
850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851 %
852 % Use only one of the two ligature tables provided!
853 % (comment out as appropriate!)
854 %
855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
856 %
857 % ligature tables for 3D dice:
858 % #a, #b, #c, #d, where # is the value on the top face,
859 % and the letter indicates the value on
860 % the front face: "a" -> smallest,
861 % "d" -> largest
862 ligtable "1" : "a" =: "a", "b" =: "b", "c" =: "c", "d" =: "d";
863 ligtable "2" : "a" =: "e", "b" =: "f", "c" =: "g", "d" =: "h";
864 ligtable "3" : "a" =: "i", "b" =: "j", "c" =: "k", "d" =: "l";
865 ligtable "4" : "a" =: "m", "b" =: "n", "c" =: "o", "d" =: "p";
866 ligtable "5" : "a" =: "q", "b" =: "r", "c" =: "s", "d" =: "t";
867 ligtable "6" : "a" =: "u", "b" =: "v", "c" =: "w", "d" =: "x";
868 %
869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870 %
871 % alternative ligature tables for 3D dice:
872 % #a, #b, #c, #d, #e, #f, where # is the value on the top face,
873 % and the letter indicates the value on
874 % the front face: "a" -> 1
875 % ... "f" -> 6
876 % ligtable "1" : "b" =: "a", "c" =: "b", "d" =: "c", "e" =: "d";
877 % ligtable "2" : "a" =: "e", "c" =: "f", "d" =: "g", "f" =: "h";
878 % ligtable "3" : "a" =: "i", "b" =: "j", "e" =: "k", "f" =: "l";
879 % ligtable "4" : "a" =: "m", "b" =: "n", "e" =: "o", "f" =: "p";
880 % ligtable "5" : "a" =: "q", "c" =: "r", "d" =: "s", "f" =: "t";
881 % ligtable "6" : "b" =: "u", "c" =: "v", "d" =: "w", "e" =: "x";
882 %
883 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884
885 end;
886