summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/base/mp-back.mp
blob: 99e88554b62645d68d4ba21ab7de2186dbf6759e (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
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
%D \module
%D   [       file=mp-back.mp,
%D        version=2000.05.31, 
%D          title=\CONTEXT\ \METAPOST\ graphics,
%D       subtitle=backgrounds,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for 
%C details. 

if unknown context_tool :    input mp-tool ; fi ; 
if   known context_back : endinput         ; fi ; 

boolean context_back ; context_back := true ; 

def some_hash ( expr hash_width     , 
                     hash_height    ,    
                     hash_linewidth , 
                     hash_linecolor , 
                     hash_angle     , 
                     hash_gap       ) = 

  stripe_gap := hash_gap ;
  stripe_angle := hash_angle ;
  drawoptions (withpen pencircle scaled hash_linewidth 
               withcolor hash_linecolor) ;
  path p ; p := unitsquare xscaled hash_width yscaled hash_height ;
  stripe_path_a () (draw) p ;  % next we move it all to quadrant 1
  currentpicture := currentpicture shifted urcorner currentpicture ; 

enddef ; 

def some_double_back (expr back_type        , 
                           back_width       ,
                           back_height      ,
                           back_delta       , 
                           back_linewidth   , 
                           back_linecolor   , 
                           back_fillcolor   , 
                           back_topcolor    , 
                           back_bottomcolor ,
                           back_leftcolor   , 
                           back_rightcolor  ) = 

  numeric ww ; ww := back_width  ; 
  numeric hh ; hh := back_height ; 
  numeric dd ; dd := back_delta  ; 

  color back_nillcolor ; back_nillcolor := back_topcolor ; 

  path p ; p := fullsquare xscaled  ww      yscaled  hh      ;  
  path q ; q := fullsquare xscaled (ww-2dd) yscaled (hh-2dd) ; 
  path r ; r := llcorner p -- 
                lrcorner p shifted (-3dd,0) .. controls lrcorner p .. 
                lrcorner p shifted (0, 3dd) -- 
                urcorner p shifted (0,-3dd) .. controls urcorner p .. 
                urcorner p shifted (-3dd,0) --
                ulcorner p -- cycle ;
  path s ; s := r xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ;
  path t ; t := llcorner p -- 
                lrcorner p -- 
                urcorner p shifted (0,-3dd) .. controls urcorner p .. 
                urcorner p shifted (-3dd,0) -- 
                ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. 
                ulcorner p shifted (0,-3dd) --
                llcorner p -- cycle ;
  path u ; u := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ;
  path v ; v := llcorner p shifted ( 3dd,0) -- 
                lrcorner p shifted (-3dd,0) .. controls lrcorner p .. 
                lrcorner p shifted (0, 3dd) -- 
                urcorner p shifted (0,-3dd) .. controls urcorner p .. 
                urcorner p shifted (-3dd,0) --
                ulcorner p shifted ( 3dd,0) .. controls ulcorner p .. 
                ulcorner p shifted (0,-3dd) ..
                llcorner p shifted (0, 3dd) .. controls llcorner p .. cycle ; % {down}  .. cycle ;
  path w ; w := t xscaled ((ww-2dd)/ww) yscaled ((hh-2dd)/hh) ;
  path a ; a := llcorner p -- ulcorner p -- 
                ulcorner q -- llcorner q -- cycle ;
  path b ; b := llcorner p -- lrcorner p -- 
                lrcorner q -- llcorner q -- cycle ;
  path c ; c := lrcorner p -- urcorner p -- 
                urcorner q -- lrcorner q -- cycle ;
  path d ; d := ulcorner p -- urcorner p -- 
                urcorner q -- ulcorner q -- cycle ;
  path e ; e := llcorner p -- lrcorner p -- 
                urcorner p -- urcorner q -- 
                lrcorner q -- llcorner q -- cycle ;
  path f ; f := llcorner p -- ulcorner p -- 
                urcorner p -- urcorner q -- 
                ulcorner q -- llcorner q -- cycle ;

  linecap := butt ; pickup pencircle scaled back_linewidth ; 

  if back_type=1 : 

    fill p withcolor back_fillcolor   ; 
    fill a withcolor back_leftcolor   ; 
    fill b withcolor back_bottomcolor ;  
    fill c withcolor back_rightcolor  ; 
    fill d withcolor back_topcolor    ; 
    draw a withcolor back_linecolor   ; 
    draw d withcolor back_linecolor   ; 
    draw b withcolor back_linecolor   ; 
    draw c withcolor back_linecolor   ; 

  elseif back_type=2 : 

    fill p withcolor back_fillcolor   ; 
    fill e withcolor back_bottomcolor ; 
    fill f withcolor back_topcolor    ; 
    draw e withcolor back_linecolor   ; 
    draw f withcolor back_linecolor   ; 

  elseif back_type=3 : 

    fill v withcolor back_nillcolor   ; 
    fill w withcolor back_fillcolor   ; 
    draw v withcolor back_linecolor   ; 
    draw w withcolor back_linecolor   ; 

  elseif back_type=4 : 

    fill t withcolor back_nillcolor   ; 
    fill u withcolor back_fillcolor   ; 
    draw t withcolor back_linecolor   ; 
    draw u withcolor back_linecolor   ; 

  elseif back_type=5 : 

    t := t rotatedaround(center t,180) ; 
    u := u rotatedaround(center u,180) ; 

    fill t withcolor back_nillcolor   ; 
    fill u withcolor back_fillcolor   ; 
    draw t withcolor back_linecolor   ; 
    draw u withcolor back_linecolor   ; 

  elseif back_type=6 : 

    r := r rotatedaround(center r,180) ; 
    s := s rotatedaround(center s,180) ; 

    fill r withcolor back_nillcolor   ; 
    fill s withcolor back_fillcolor   ; 
    draw r withcolor back_linecolor   ; 
    draw s withcolor back_linecolor   ; 

  elseif back_type=7 : 

    fill r withcolor back_nillcolor   ; 
    fill s withcolor back_fillcolor   ; 
    draw r withcolor back_linecolor   ; 
    draw s withcolor back_linecolor   ; 

fi ; 

enddef ; 

endinput ;

beginfig (1) ; 

some_double_back (1, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, .6white, .7white, .6white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (2, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, .6white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (3, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (4, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (5, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (6, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (7, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

currentpicture := currentpicture shifted (0,-3cm) ; 

some_double_back (8, 4.5cm, 1.5cm, .25cm, 1mm, 
           .5white, .8white, .7white, white, white, white)

endfig ; 

end .