summaryrefslogtreecommitdiff
path: root/info/examples/lgc2/4-1-13.mp
blob: cfa3776144920e18fd86f32a797e73c616c1269b (plain)
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
% --- start of displayed preamble in the book ---
input hatching;
% star macro defined as above
% --- end of displayed preamble in the book ---

% graphic converted to gray in book using 'color2gray'

vardef star(expr n) =
 for i_:=0 upto 2n-1:
  if odd i_: 1/2 fi (right rotated (180*(i_/n))) --
 endfor cycle
enddef;

defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
path p;
p:=star(10) xscaled 20mm yscaled 20mm;
save draw_hatched_band;
vardef draw_hatched_band(expr za,zb,a,l,d) =
  save n_; n_:=length(za-zb)/l;
  for i_:=0 upto ceiling n_:
    fill star(10) xscaled 2/5l yscaled 2/5l
      shifted (i_/n_)[za,zb]
      withcolor (i_/n_)[green,blue];
  endfor
enddef;
hatchfill p withcolor (red+green)
            withcolor (45,10bp,-1bp);
endfig;
end;