Debian Codegraph @

texmf-dist/doc/metapost/hatching/htchuse.mp

raw
1 %%% addto hatchfill
2 %%% addto beginfig
3 %%% enddef endfig
4 %%% length withcolor dashed off on
5 % This is a sample file demonstrating how one can use the macros defined
6 % in hatching.mp.
7
8 input hatching.mp;
9
10 vardef star(expr n) =
11 for i_:=0 upto 2n-1:
12 if odd i_: 1/2 fi (right rotated (180*(i_/n))) --
13 endfor cycle
14 enddef;
15
16 beginfig(100);
17 path p; p:=unitsquare xscaled 50mm yscaled 25mm;
18 hatchfill p withcolor red withcolor (45,2mm,-.5bp) withcolor (-45,2mm,-.5bp);
19
20 endfig;
21
22 beginfig(101);
23 interim hatch_match:=0;
24 path p; p:=star(10) xscaled 35mm yscaled 20mm rotated 20;
25 hatchfill p withcolor (0,1,.5);
26 draw image(hatchfill p
27 withcolor (45,3bp,-.5bp) withcolor (-45,3bp,-.5bp);
28 ) withcolor red dashed evenly; % |evenly=dashpattern(on 3bp off 3bp)|
29 endfig;
30
31 beginfig(102);
32 path p; p:=star(10) xscaled 35mm yscaled 20mm rotated 20;
33 interim hatch_match:=0;
34 hatchoptions(withcolor blue dashed evenly scaled 2);
35 hatchfill p withcolor .75white withcolor (20,6bp,-.5bp);
36 hatchoptions(withcolor (blue+green) dashed evenly shifted (3/2bp,0));
37 hatchfill p withcolor (110,6bp,-.5bp);
38 endfig;
39
40 beginfig(103);
41 path p; p:=star(10) xscaled 35mm yscaled 35mm;
42 save draw_hatched_band;
43 vardef draw_hatched_band(expr za,zb,a,l,d) =
44 save n_; n_:=length(za-zb)/l;
45 for i_:=0 upto ceiling n_:
46 fill star(10) xscaled 2/5l yscaled 2/5l
47 shifted (i_/n_)[za,zb] withcolor (i_/n_)[green,blue];
48 endfor
49 enddef;
50 hatchfill p withcolor (red+green) withcolor (45,10bp,-1bp);
51 endfig;
52
53 end.
54 %%\end
55