grph-rul.lua /size: 17 Kb    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
grph-rul
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to grph-rul.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
local
tonumber
,
next
,
type
=
tonumber
,
next
,
type
10
local
concat
=
table
.
concat
11 12
local
attributes
=
attributes
13
local
nodes
=
nodes
14
local
context
=
context
15 16
local
bpfactor
=
number
.
dimenfactors
.
bp
17 18
local
nuts
=
nodes
.
nuts
19
local
nodepool
=
nuts
.
pool
20
local
userrule
=
nuts
.
rules
.
userrule
21
local
outlinerule
=
nuts
.
pool
.
outlinerule
22
local
ruleactions
=
nuts
.
rules
.
ruleactions
23 24
local
setattrlist
=
nuts
.
setattrlist
25
local
setattr
=
nuts
.
setattr
26
local
tonode
=
nuts
.
tonode
27 28
local
getattribute
=
tex
.
getattribute
29
local
getwhd
=
nuts
.
getwhd
30
local
setwhd
=
nuts
.
setwhd
31 32
local
lefttoright_code
=
nodes
.
dirvalues
.
lefttoright
33 34
local
a_color
=
attributes
.
private
(
'
color
'
)
35
local
a_transparency
=
attributes
.
private
(
'
transparency
'
)
36
local
a_colormodel
=
attributes
.
private
(
'
colormodel
'
)
37 38
local
mpcolor
=
attributes
.
colors
.
mpcolor
39 40
local
trace_mp
=
false
trackers
.
register
(
"
rules.mp
"
,
function
(
v
)
trace_mp
=
v
end
)
41 42
local
report_mp
=
logs
.
reporter
(
"
rules
"
,
"
mp
"
)
43 44
local
floor
=
math
.
floor
45
local
getrandom
=
utilities
.
randomizer
.
get
46
local
formatters
=
string
.
formatters
47 48
-- This is very pdf specific. Maybe move some to lpdf-rul.lua some day.
49 50
local
pdfprint
51 52
pdfprint
=
function
(
...
)
pdfprint
=
lpdf
.
print
return
pdfprint
(
...
)
end
53 54
updaters
.
register
(
"
backend.update
"
,
function
(
)
55
pdfprint
=
lpdf
.
print
56
end
)
57 58
do
59 60
local
simplemetapost
=
metapost
.
simple
61
local
cachesize
=
0
62
local
maxcachesize
=
256
*
1024
63
local
cachethreshold
=
1024
64
local
caching
=
false
-- otherwise random issues so we need a dedicated randomizer first
65 66
-- local maxcachesize = 8*1024
67
-- local cachethreshold = 1024/2
68 69
local
cache
=
table
.
setmetatableindex
(
function
(
t
,
k
)
70
local
v
=
simplemetapost
(
"
rulefun
"
,
k
)
-- w, h, d
71
cachesize
=
cachesize
+
#
v
72
if
cachesize
>
maxcachesize
then
73
-- print("old",cachesize)
74
for
k
,
v
in
next
,
t
do
75
local
n
=
#
v
76
if
n
>
cachethreshold
then
77
t
[
k
]
=
nil
78
cachesize
=
cachesize
-
n
79
end
80
end
81
-- print("new",cachesize)
82
end
83
-- print(cachesize,maxcachesize,cachethreshold,#v)
84
t
[
k
]
=
v
85
return
v
86
end
)
87 88
local
replacer
=
utilities
.
templates
.
replacer
89 90
local
predefined
=
{
91
[
"
fake:word
"
]
=
replacer
[[
92FakeWord(%width%,%height%,%depth%,%line%,%color%); 93
]]
,
94
[
"
fake:rule
"
]
=
replacer
[[
95%initializations% 96FakeRule(%width%,%height%,%depth%,%line%,%color%); 97
]]
,
98
[
"
fake:rest
"
]
=
replacer
[[
99RuleDirection := "%direction%" ; 100RuleOption := "%option%" ; 101RuleWidth := %width% ; 102RuleHeight := %height% ; 103RuleDepth := %depth% ; 104RuleH := %h% ; 105RuleV := %v% ; 106RuleThickness := %line% ; 107RuleFactor := %factor% ; 108RuleOffset := %offset% ; 109def RuleColor = %color% enddef ; 110%data%; 111
]]
112
}
113 114
local
initialized
=
false
;
115 116
ruleactions
.
mp
=
function
(
p
,
h
,
v
,
i
,
n
)
117
local
name
=
p
.
name
or
"
fake:rest
"
118
local
code
=
(
predefined
[
name
]
or
predefined
[
"
fake:rest
"
]
)
{
119
data
=
p
.
data
or
"
"
,
120
width
=
p
.
width
*
bpfactor
,
121
height
=
p
.
height
*
bpfactor
,
122
depth
=
p
.
depth
*
bpfactor
,
123
factor
=
(
p
.
factor
or
0
)
*
bpfactor
,
-- needs checking
124
offset
=
p
.
offset
or
0
,
125
line
=
(
p
.
line
or
65536
)
*
bpfactor
,
126
color
=
mpcolor
(
p
.
ma
,
p
.
ca
,
p
.
ta
)
,
127
option
=
p
.
option
or
"
"
,
128
direction
=
p
.
direction
or
lefttoright_code
,
129
h
=
h
*
bpfactor
,
130
v
=
v
*
bpfactor
,
131
}
132
if
not
initialized
then
133
initialized
=
true
134
simplemetapost
(
"
rulefun
"
,
formatters
[
"
randomseed := %s;
"
]
(
getrandom
(
"
rulefun
"
,
0
,
4095
)
)
)
135
end
136
local
pdf
=
caching
and
cache
[
code
]
or
simplemetapost
(
"
rulefun
"
,
code
)
-- w, h, d
137
if
trace_mp
then
138
report_mp
(
"
code: %s
"
,
code
)
139
report_mp
(
"
pdf : %s
"
,
pdf
)
140
end
141
if
pdf
and
pdf
~
=
"
"
then
142
pdfprint
(
"
direct
"
,
pdf
)
143
end
144
end
145 146
end
147 148
do
149 150
-- This is the old oval method that we keep it for compatibility reasons. Of
151
-- course one can use mp instead. It could be improved but at the cost of more
152
-- code than I'm willing to add for something hardly used.
153 154
local
function
round
(
p
,
kind
)
155
local
method
=
tonumber
(
p
.
corner
)
or
0
156
if
method
<
0
or
method
>
27
then
157
method
=
0
158
end
159
local
width
=
p
.
width
or
0
160
local
height
=
p
.
height
or
0
161
local
depth
=
p
.
depth
or
0
162
local
total
=
height
+
depth
163
local
radius
=
p
.
radius
or
655360
164
local
line
=
p
.
line
or
65536
165
local
how
=
(
method
>
8
or
kind
~
=
"
fill
"
)
and
"
S
"
or
"
f
"
166
local
half
=
line
/
2
167
local
xmin
=
half
*
bpfactor
168
local
xmax
=
(
width
-
half
)
*
bpfactor
169
local
ymax
=
(
height
-
half
)
*
bpfactor
170
local
ymin
=
(
-
depth
+
half
)
*
bpfactor
171
local
full
=
(
radius
+
half
)
172
local
xxmin
=
full
*
bpfactor
173
local
xxmax
=
(
width
-
full
)
*
bpfactor
174
local
yymax
=
(
height
-
full
)
*
bpfactor
175
local
yymin
=
(
-
depth
+
full
)
*
bpfactor
176
line
=
line
*
bpfactor
177
if
xxmin
<
=
xxmax
and
yymin
<
=
yymax
then
178
local
list
=
nil
179
if
method
=
=
0
then
180
list
=
{
181
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xxmax
,
ymin
,
"
l
"
,
xmax
,
ymin
,
xmax
,
yymin
,
"
y
"
,
182
xmax
,
yymax
,
"
l
"
,
xmax
,
ymax
,
xxmax
,
ymax
,
"
y
"
,
xxmin
,
ymax
,
"
l
"
,
xmin
,
ymax
,
183
xmin
,
yymax
,
"
y
"
,
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
"
y
"
,
"
h
"
,
how
,
"
Q
"
,
184
}
185
elseif
method
=
=
1
then
186
list
=
{
187
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xxmax
,
ymin
,
"
l
"
,
xmax
,
ymin
,
xmax
,
yymin
,
"
y
"
,
188
xmax
,
ymax
,
"
l
"
,
xmin
,
ymax
,
"
l
"
,
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
"
y
"
,
189
"
h
"
,
how
,
"
Q
"
,
190
}
191
elseif
method
=
=
2
then
192
list
=
{
193
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xmax
,
ymin
,
"
l
"
,
xmax
,
ymax
,
"
l
"
,
xxmin
,
ymax
,
194
"
l
"
,
xmin
,
ymax
,
xmin
,
yymax
,
"
y
"
,
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
195
"
y
"
,
"
h
"
,
how
,
"
Q
"
,
196
}
197
elseif
method
=
=
3
then
198
list
=
{
199
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xmax
,
ymin
,
"
l
"
,
xmax
,
yymax
,
"
l
"
,
xmax
,
ymax
,
200
xxmax
,
ymax
,
"
y
"
,
xxmin
,
ymax
,
"
l
"
,
xmin
,
ymax
,
xmin
,
yymax
,
"
y
"
,
xmin
,
ymin
,
201
"
l
"
,
"
h
"
,
how
,
"
Q
"
,
202
}
203 204
elseif
method
=
=
4
then
205
list
=
{
206
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xxmax
,
ymin
,
"
l
"
,
xmax
,
ymin
,
xmax
,
yymin
,
"
y
"
,
207
xmax
,
yymax
,
"
l
"
,
xmax
,
ymax
,
xxmax
,
ymax
,
"
y
"
,
xmin
,
ymax
,
"
l
"
,
xmin
,
ymin
,
"
l
"
,
208
"
h
"
,
how
,
"
Q
"
,
209
}
210
elseif
method
=
=
5
then
211
list
=
{
212
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xmax
,
ymin
,
"
l
"
,
xmax
,
yymax
,
"
l
"
,
xmax
,
ymax
,
213
xxmax
,
ymax
,
"
y
"
,
xmin
,
ymax
,
"
l
"
,
xmin
,
ymin
,
"
l
"
,
"
h
"
,
how
,
"
Q
"
,
214
}
215
elseif
method
=
=
6
then
216
list
=
{
217
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xxmax
,
ymin
,
"
l
"
,
xmax
,
ymin
,
xmax
,
yymin
,
"
y
"
,
218
xmax
,
ymax
,
"
l
"
,
xmin
,
ymax
,
"
l
"
,
xmin
,
ymin
,
"
l
"
,
"
h
"
,
how
,
"
Q
"
,
219
}
220
elseif
method
=
=
7
then
221
list
=
{
222
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xmax
,
ymin
,
"
l
"
,
xmax
,
ymax
,
"
l
"
,
xmin
,
ymax
,
223
"
l
"
,
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
"
y
"
,
"
h
"
,
how
,
"
Q
"
,
224
}
225
elseif
method
=
=
8
then
226
list
=
{
227
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xmax
,
ymin
,
"
l
"
,
xmax
,
ymax
,
"
l
"
,
xxmin
,
ymax
,
228
"
l
"
,
xmin
,
ymax
,
xmin
,
yymax
,
"
y
"
,
xmin
,
ymin
,
"
l
"
,
"
h
"
,
how
,
"
Q
"
,
229
}
230
elseif
method
=
=
9
then
231
list
=
{
232
"
q
"
,
line
,
"
w
"
,
xmin
,
ymax
,
"
m
"
,
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
"
y
"
,
233
xxmax
,
ymin
,
"
l
"
,
xmax
,
ymin
,
xmax
,
yymin
,
"
y
"
,
xmax
,
ymax
,
"
l
"
,
how
,
"
Q
"
,
234
}
235
elseif
method
=
=
10
then
236
list
=
{
237
"
q
"
,
line
,
"
w
"
,
xmax
,
ymax
,
"
m
"
,
xxmin
,
ymax
,
"
l
"
,
xmin
,
ymax
,
xmin
,
yymax
,
"
y
"
,
238
xmin
,
yymin
,
"
l
"
,
xmin
,
ymin
,
xxmin
,
ymin
,
"
y
"
,
xmax
,
ymin
,
"
l
"
,
how
,
"
Q
"
,
239
}
240
elseif
method
=
=
11
then
241
list
=
{
242
"
q
"
,
line
,
"
w
"
,
xmax
,
ymin
,
"
m
"
,
xmax
,
yymax
,
"
l
"
,
xmax
,
ymax
,
xxmax
,
ymax
,
"
y
"
,
243
xxmin
,
ymax
,
"
l
"
,
xmin
,
ymax
,
xmin
,
yymax
,
"
y
"
,
xmin
,
ymin
,
"
l
"
,
how
,
"
Q
"
,
244
}
245
elseif
method
=
=
12
then
246
list
=
{
247
"
q
"
,
line
,
"
w
"
,
xmin
,
ymax
,
"
m
"
,
xxmax
,
ymax
,
"
l
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
248
xmax
,
yymin
,
"
l
"
,
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
xmin
,
ymin
,
"
l
"
,
how
,
"
Q
"
,
249
}
250
elseif
method
=
=
13
then
251
list
=
{
252
"
q
"
,
line
,
"
w
"
,
xmin
,
ymax
,
"
m
"
,
xxmax
,
ymax
,
"
l
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
253
xmax
,
ymin
,
"
l
"
,
how
,
"
Q
"
,
254
}
255
elseif
method
=
=
14
then
256
list
=
{
257
"
q
"
,
line
,
"
w
"
,
xmax
,
ymax
,
"
m
"
,
xmax
,
yymin
,
"
l
"
,
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
258
xmin
,
ymin
,
"
l
"
,
how
,
"
Q
"
,
259
}
260
elseif
method
=
=
15
then
261
list
=
{
262
"
q
"
,
line
,
"
w
"
,
xmax
,
ymin
,
"
m
"
,
xxmin
,
ymin
,
"
l
"
,
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
263
xmin
,
ymax
,
"
l
"
,
how
,
"
Q
"
,
264
}
265
elseif
method
=
=
16
then
266
list
=
{
267
"
q
"
,
line
,
"
w
"
,
xmin
,
ymin
,
"
m
"
,
xmin
,
yymax
,
"
l
"
,
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
268
xmax
,
ymax
,
"
l
"
,
how
,
"
Q
"
,
269
}
270
elseif
method
=
=
17
then
271
list
=
{
272
"
q
"
,
line
,
"
w
"
,
xxmax
,
ymax
,
"
m
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
how
,
"
Q
"
,
273
}
274
elseif
method
=
=
18
then
275
list
=
{
276
"
q
"
,
line
,
"
w
"
,
xmax
,
yymin
,
"
m
"
,
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
how
,
"
Q
"
,
277
}
278
elseif
method
=
=
19
then
279
list
=
{
280
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
how
,
"
Q
"
,
281
}
282
elseif
method
=
=
20
then
283
list
=
{
284
"
q
"
,
line
,
"
w
"
,
xmin
,
yymax
,
"
m
"
,
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
how
,
"
Q
"
,
285
}
286
elseif
method
=
=
21
then
287
list
=
{
288
"
q
"
,
line
,
"
w
"
,
xxmax
,
ymax
,
"
m
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
xmin
,
yymax
,
"
m
"
,
289
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
how
,
"
Q
"
,
290
}
291
elseif
method
=
=
22
then
292
list
=
{
293
"
q
"
,
line
,
"
w
"
,
xxmax
,
ymax
,
"
m
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
xmax
,
yymin
,
"
m
"
,
294
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
how
,
"
Q
"
,
295
}
296
elseif
method
=
=
23
then
297
list
=
{
298
"
q
"
,
line
,
"
w
"
,
xmax
,
yymin
,
"
m
"
,
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
xxmin
,
ymin
,
"
m
"
,
299
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
how
,
"
Q
"
,
300
}
301
elseif
method
=
=
24
then
302
list
=
{
303
"
q
"
,
line
,
"
w
"
,
xxmin
,
ymin
,
"
m
"
,
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
xmin
,
yymax
,
"
m
"
,
304
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
how
,
"
Q
"
,
305
}
306
elseif
method
=
=
25
then
307
list
=
{
308
"
q
"
,
line
,
"
w
"
,
xxmax
,
ymax
,
"
m
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
xmax
,
yymin
,
"
m
"
,
309
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
xxmin
,
ymin
,
"
m
"
,
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
310
xmin
,
yymax
,
"
m
"
,
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
how
,
"
Q
"
,
311
}
312
elseif
method
=
=
26
then
313
list
=
{
314
"
q
"
,
line
,
"
w
"
,
xmax
,
yymin
,
"
m
"
,
xmax
,
ymin
,
xxmax
,
ymin
,
"
y
"
,
xmin
,
yymax
,
"
m
"
,
315
xmin
,
ymax
,
xxmin
,
ymax
,
"
y
"
,
how
,
"
Q
"
,
316
}
317 318
elseif
method
=
=
27
then
319
list
=
{
320
"
q
"
,
line
,
"
w
"
,
xxmax
,
ymax
,
"
m
"
,
xmax
,
ymax
,
xmax
,
yymax
,
"
y
"
,
xxmin
,
ymin
,
"
m
"
,
321
xmin
,
ymin
,
xmin
,
yymin
,
"
y
"
,
how
,
"
Q
"
,
322
}
323
end
324
pdfprint
(
"
direct
"
,
concat
(
list
,
"
"
)
)
325
end
326
end
327 328
local
f_rectangle
=
formatters
[
"
%.6N w %.6N %.6N %.6N %.6N re %s
"
]
329
local
f_baselined
=
formatters
[
"
%.6N w %.6N %.6N %.6N %.6N re s %.6N %.6N m %.6N %.6N l s
"
]
330
local
f_dashlined
=
formatters
[
"
%.6N w %.6N %.6N %.6N %.6N re s [%.6N %.6N] 2 d %.6N %.6N m %.6N %.6N l s
"
]
331
local
f_radtangle
=
formatters
[
332
[[
%.6N w %.6N %.6N m 333%.6N %.6N l %.6N %.6N %.6N %.6N y 334%.6N %.6N l %.6N %.6N %.6N %.6N y 335%.6N %.6N l %.6N %.6N %.6N %.6N y 336%.6N %.6N l %.6N %.6N %.6N %.6N y 337h %s
]]
338
]
339 340
ruleactions
.
fill
=
function
(
p
,
h
,
v
,
i
,
n
)
341
if
p
.
corner
then
342
return
round
(
p
,
i
)
343
else
344
local
l
=
(
p
.
line
or
65536
)
*
bpfactor
345
local
r
=
p
and
(
p
.
radius
or
0
)
*
bpfactor
or
0
346
local
w
=
h
*
bpfactor
347
local
h
=
v
*
bpfactor
348
local
m
=
nil
349
local
t
=
i
=
=
"
fill
"
and
"
f
"
or
"
s
"
350
local
o
=
l
/
2
351
if
r
>
0
then
352
w
=
w
-
o
353
h
=
h
-
o
354
m
=
f_radtangle
(
l
,
r
,
o
,
w
-
r
,
o
,
w
,
o
,
w
,
r
,
w
,
h
-
r
,
w
,
h
,
w
-
r
,
h
,
r
,
h
,
o
,
h
,
o
,
h
-
r
,
o
,
r
,
o
,
o
,
r
,
o
,
t
)
355
else
356
w
=
w
-
l
357
h
=
h
-
l
358
m
=
f_rectangle
(
l
,
o
,
o
,
w
,
h
,
t
)
359
end
360
pdfprint
(
"
direct
"
,
m
)
361
end
362
end
363 364
ruleactions
.
draw
=
ruleactions
.
fill
365
ruleactions
.
stroke
=
ruleactions
.
fill
366 367
ruleactions
.
box
=
function
(
p
,
h
,
v
,
i
,
n
)
368
local
w
,
h
,
d
=
getwhd
(
n
)
369
local
line
=
p
.
line
or
65536
370
local
l
=
line
*
bpfactor
371
local
w
=
w
*
bpfactor
372
local
h
=
h
*
bpfactor
373
local
d
=
d
*
bpfactor
374
local
o
=
l
/
2
375
if
(
d
>
=
0
and
h
>
=
0
)
or
(
d
<
=
0
and
h
<
=
0
)
then
376
local
dashed
=
tonumber
(
p
.
dashed
)
377
if
dashed
and
dashed
>
5
*
line
then
378
dashed
=
dashed
*
bpfactor
379
local
delta
=
(
w
-
2
*
dashed
*
floor
(
w
/
(
2
*
dashed
)
)
)
/
2
380
pdfprint
(
"
direct
"
,
f_dashlined
(
l
,
o
,
o
,
w
-
l
,
h
+
d
-
l
,
dashed
,
dashed
,
delta
,
d
,
w
-
delta
,
d
)
)
381
else
382
pdfprint
(
"
direct
"
,
f_baselined
(
l
,
o
,
o
,
w
-
l
,
h
+
d
-
l
,
0
,
d
,
w
,
d
)
)
383
end
384
else
385
pdfprint
(
"
direct
"
,
f_rectangle
(
l
,
o
,
o
,
w
-
l
,
h
+
d
-
l
)
)
386
end
387
end
388 389
end
390 391
interfaces
.
implement
{
392
name
=
"
frule
"
,
393
arguments
=
{
{
394
{
"
width
"
,
"
dimension
"
}
,
395
{
"
height
"
,
"
dimension
"
}
,
396
{
"
depth
"
,
"
dimension
"
}
,
397
{
"
radius
"
,
"
dimension
"
}
,
398
{
"
line
"
,
"
dimension
"
}
,
399
{
"
type
"
,
"
string
"
}
,
400
{
"
data
"
,
"
string
"
}
,
401
{
"
name
"
,
"
string
"
}
,
402
{
"
radius
"
,
"
dimension
"
}
,
403
{
"
corner
"
,
"
string
"
}
,
404
}
}
,
405
actions
=
function
(
t
)
406
local
rule
=
userrule
(
t
)
407
if
t
.
type
=
=
"
mp
"
then
408
t
.
ma
=
getattribute
(
a_colormodel
)
or
1
409
t
.
ca
=
getattribute
(
a_color
)
410
t
.
ta
=
getattribute
(
a_transparency
)
411
else
412
setattrlist
(
rule
,
true
)
413
end
414
context
(
tonode
(
rule
)
)
-- will become context.nodes.flush
415
end
416
}
417 418
interfaces
.
implement
{
419
name
=
"
outlinerule
"
,
420
public
=
true
,
421
protected
=
true
,
422
arguments
=
{
{
423
{
"
width
"
,
"
dimension
"
}
,
424
{
"
height
"
,
"
dimension
"
}
,
425
{
"
depth
"
,
"
dimension
"
}
,
426
{
"
line
"
,
"
dimension
"
}
,
427
}
}
,
428
actions
=
function
(
t
)
429
local
rule
=
outlinerule
(
t
.
width
,
t
.
height
,
t
.
depth
,
t
.
line
)
430
setattrlist
(
rule
,
true
)
431
context
(
tonode
(
rule
)
)
-- will become context.nodes.flush
432
end
433
}
434 435
interfaces
.
implement
{
436
name
=
"
framedoutline
"
,
437
arguments
=
{
"
dimension
"
,
"
dimension
"
,
"
dimension
"
,
"
dimension
"
}
,
438
actions
=
function
(
w
,
h
,
d
,
l
)
439
local
rule
=
outlinerule
(
w
,
h
,
d
,
l
)
440
setattrlist
(
rule
,
true
)
441
context
(
tonode
(
rule
)
)
-- will become context.nodes.flush
442
end
443
}
444 445
interfaces
.
implement
{
446
name
=
"
fakeword
"
,
447
arguments
=
{
{
448
{
"
factor
"
,
"
dimension
"
}
,
449
{
"
name
"
,
"
string
"
}
,
-- can be type
450
{
"
min
"
,
"
dimension
"
}
,
451
{
"
max
"
,
"
dimension
"
}
,
452
{
"
n
"
,
"
integer
"
}
,
453
}
}
,
454
actions
=
function
(
t
)
455
local
factor
=
t
.
factor
or
0
456
local
amount
=
getrandom
(
"
fakeword
"
,
t
.
min
,
t
.
max
)
457
local
rule
=
userrule
{
458
height
=
1
.
25
*
factor
,
459
depth
=
0
.
25
*
factor
,
460
width
=
floor
(
amount
/
10000
)
*
10000
,
461
line
=
0
.
10
*
factor
,
462
ma
=
getattribute
(
a_colormodel
)
or
1
,
463
ca
=
getattribute
(
a_color
)
,
464
ta
=
getattribute
(
a_transparency
)
,
465
type
=
"
mp
"
,
466
name
=
t
.
name
,
467
}
468
setattrlist
(
rule
,
true
)
469
context
(
tonode
(
rule
)
)
470
end
471
}
472